/* Hallmark · genre: modern-minimal · macrostructure: multi-page Cobalt system · design-system: design.md · designed-as-app */
/* Hallmark · pre-emit critique: P5 H5 E5 S4 R5 V4 */

html,
body {
  background: var(--color-paper);
  color: var(--color-ink-2);
  font-family: var(--font-body);
}

body {
  line-height: 1.6;
}

/* Hallmark · component: native scrollbar · genre: modern-minimal · theme: Cobalt
 * states: default · hover · active (native control; disabled/loading/error/success do not apply)
 * contrast: pass (46–50)
 */
html,
body,
* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklch, var(--color-muted) 46%, transparent) transparent;
}

*::-webkit-scrollbar {
  width: var(--space-xs);
  height: var(--space-xs);
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: var(--space-3xs) solid transparent;
  border-radius: var(--radius-control);
  background: color-mix(in oklch, var(--color-muted) 46%, transparent);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: color-mix(in oklch, var(--color-muted) 68%, transparent);
}

*::-webkit-scrollbar-thumb:active {
  background-color: var(--color-rule-strong);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-popover, 10);
  border-bottom: var(--rule);
  background: var(--color-paper-glass);
  box-shadow: none;
}

.nav {
  width: min(100%, 78rem);
  min-height: 4.25rem;
  margin: 0 auto;
  padding: 0 var(--space-md);
  align-items: center;
}

.nav-left {
  min-width: 0;
  gap: var(--space-xl);
}

.brand {
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.04em;
  transform: none;
}

.nav ul {
  gap: var(--space-md);
}

.nav a:not(.brand) {
  min-height: 2.75rem;
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.nav a:not(.brand):hover,
.nav a:not(.brand).active {
  color: var(--color-accent);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-left: auto;
  flex-shrink: 0;
}

.nav-command,
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  border: var(--rule);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  white-space: nowrap;
}

.nav-command {
  gap: var(--space-2xs);
  padding: 0 var(--space-xs);
}

@media (hover: hover) {
  .nav-command:hover,
  .nav-toggle:hover,
  .command-palette__close:hover {
    border-color: var(--color-rule-strong);
    background: var(--color-paper-2);
  }
}

.nav-command:active,
.nav-toggle:active,
.command-palette__close:active {
  transform: translateY(1px);
}

.nav-command:disabled,
.nav-toggle:disabled,
.command-palette__close:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.nav-command kbd {
  color: var(--color-muted);
  font: inherit;
}

.nav-toggle {
  display: none;
  padding: 0 var(--space-xs);
}

.site-main {
  min-height: calc(100dvh - 8.5rem);
}

.landing-page {
  width: min(100%, 78rem);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md) var(--space-2xl);
}

.landing-page h1,
.landing-page h2,
.landing-page h3 {
  color: var(--color-ink);
  font-family: var(--font-display);
  font-style: normal;
  letter-spacing: -0.045em;
}

.landing-page h1 {
  min-width: 0;
  max-width: 13ch;
  margin: 0;
  font-size: var(--text-display);
  font-weight: 600;
  line-height: 0.9;
  overflow-wrap: anywhere;
}

.about-page .about-identity h1 {
  max-width: none;
  font-size: clamp(var(--text-2xl), 4vw, var(--text-3xl));
  white-space: nowrap;
}

.landing-page h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.05;
}

.entry-meta,
.system-label,
.collection-label,
.command-palette__label {
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.landing-intro,
.page-intro {
  max-width: 62ch;
  margin: var(--space-lg) 0 0;
  color: var(--color-ink-2);
  font-size: var(--text-md);
  line-height: 1.62;
}

.landing-intro p,
.page-intro p {
  margin: 0 0 var(--space-md);
}

.about-identity {
  min-width: 0;
}

.about-body {
  display: grid;
  grid-template-areas: "copy portrait";
  grid-template-columns: minmax(0, 1fr) minmax(12rem, 16rem);
  gap: var(--space-md);
  align-items: stretch;
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: var(--rule);
}

.about-meta {
  margin-top: var(--space-sm);
}

.chinese-name {
  margin: 0;
  color: var(--color-ink-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.03em;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  gap: var(--space-2xs);
}

.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  width: auto;
  height: 2.75rem;
  padding: 0 var(--space-xs);
  border: var(--rule);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-decoration: none;
  transition: none;
  white-space: nowrap;
}

.social-icon:hover {
  background: var(--color-surface);
  box-shadow: none;
  color: var(--color-ink);
  transform: none;
}

.social-icon img {
  width: 1.25rem;
  height: 1.25rem;
  filter: invert(1);
}

.social-icon.linkedin-icon img {
  filter: none;
}

.social-icon.email-icon {
  color: var(--color-ink);
}

.contact-links {
  margin-top: var(--space-md);
}

.legacy-social-links {
  display: none;
}

.about-portrait {
  grid-area: portrait;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: var(--space-sm);
  width: min(100%, clamp(12rem, calc(28vw + var(--space-2xs)), 16rem));
  max-width: none;
  min-height: 0;
  margin: 0;
  justify-self: start;
}

.profile-image {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  width: clamp(7.5rem, calc(10vw + 6.5rem), 12.5rem);
  height: auto;
  min-height: 0;
  margin: 0;
  box-shadow: none;
}

.profile-image:hover {
  box-shadow: none;
}

.profile-image img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  object-position: top left;
}

.about-portrait .social-links {
  width: auto;
  justify-content: flex-start;
  gap: var(--space-sm);
  justify-self: start;
}

.about-copy {
  grid-area: copy;
  max-width: 78ch;
  min-width: 0;
  margin-top: 0;
}

.about-copy p {
  margin: 0 0 var(--space-md);
  color: var(--color-ink-2);
  font-size: var(--text-md);
  overflow-wrap: anywhere;
}

.landing-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: var(--rule);
}

.section-rail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.landing-list,
.project-index,
.fun-stream {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: var(--rule);
}

.landing-list li,
.project-index li,
.fun-stream > li {
  margin: 0;
  padding: var(--space-md) 0;
  border-bottom: var(--rule);
  background: transparent;
  box-shadow: none;
}

.landing-list li:hover,
.project-index li:hover,
.fun-stream > li:hover {
  box-shadow: none;
}

.landing-list a,
.project-index a {
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  text-decoration: none;
}

.landing-list a:hover,
.project-index a:hover {
  color: var(--color-accent);
}

.landing-list small,
.entry-meta {
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.projects-page,
.blog-page,
.fun-page {
  display: block;
}

.collection-hero {
  display: block;
  min-height: 7rem;
  padding: var(--space-sm) clamp(var(--space-xs), 2.5vw, var(--space-xl));
  border-bottom: var(--rule);
}

.collection-hero > :first-child {
  display: flex;
  align-items: center;
  min-height: 5rem;
  padding-left: 0;
}

.collection-hero .page-intro {
  max-width: 48rem;
  margin: var(--space-sm) 0 0;
  font-size: var(--text-base);
  line-height: 1.55;
}

.collection-hero .page-intro p {
  margin-bottom: 0;
}

.collection-hero h1 {
  font-size: clamp(var(--text-2xl), calc(3vw + var(--space-xs)), var(--text-3xl));
}

.projects-page .project-index,
.blog-page .blog-layout,
.fun-page .fun-stream {
  margin-left: clamp(var(--space-xs), 2.5vw, var(--space-xl));
}

.projects-page .project-index,
.fun-page .fun-stream {
  max-width: none;
  margin-top: var(--space-lg);
}

.project-index .project-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-md);
  row-gap: var(--space-xs);
}

.project-index .project-summary {
  grid-column: 1 / -1;
  max-width: 62ch;
}

.project-index .project-summary p {
  margin: 0;
  color: var(--color-ink-2);
}

.project-index span {
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
}

.blog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13rem;
  gap: clamp(var(--space-lg), 5vw, var(--space-3xl));
  margin-top: var(--space-lg);
}

.blog-list .post-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-md);
  row-gap: var(--space-xs);
}

/* The grid declaration above otherwise overrides the browser's hidden state. */
.blog-list .post-item[hidden] {
  display: none;
}

.blog-list .post-item p {
  grid-column: 1 / -1;
  max-width: 62ch;
  margin: 0;
  color: var(--color-ink-2);
}

.blog-filter-panel {
  align-self: start;
  padding: var(--space-md);
  border: var(--rule);
  background: var(--color-surface);
}

.tag-filters {
  gap: var(--space-2xs);
  margin: 0;
}

.category-label {
  margin-bottom: var(--space-xs);
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tag-btn {
  min-height: 2.5rem;
  padding: var(--space-2xs) 0;
  color: var(--color-ink-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.tag-btn:hover,
.tag-btn.active {
  color: var(--color-accent);
}

.fun-stream {
  max-width: 62rem;
}

.fun-stream > li p {
  max-width: 70ch;
}

.fun-stream > li {
  color: var(--color-ink-2);
  font-size: var(--text-base);
}

.fun-stream small {
  font-size: inherit;
}

.fun-stream a,
.clickable-fore,
.clickable-music {
  color: var(--color-accent);
}

.fun-stream a:hover,
.clickable-fore:hover,
.clickable-music:hover {
  color: var(--color-ink);
}

.landing-page a:not(.social-icon) {
  color: var(--color-accent);
  text-decoration-color: color-mix(in oklch, var(--color-accent) 50%, transparent);
  text-underline-offset: 0.16em;
}

.landing-page a:not(.social-icon):hover {
  color: var(--color-ink);
  text-decoration-color: currentColor;
}

.landing-list a,
.project-index a {
  text-decoration: none;
}

.post-hero {
  grid-template-columns: minmax(0, 1fr);
}

.post-hero .post-heading {
  grid-column: 1 / -1;
  max-width: 100%;
}

.post-hero .entry-meta {
  margin: 0 0 var(--space-sm);
}

.post-hero h1 {
  display: block;
  width: 100%;
  max-width: 100%;
  font-size: clamp(var(--text-2xl), 4vw + 0.75rem, var(--text-display));
  line-height: 0.94;
}

.post-hero .post-heading--long h1 {
  max-width: 100%;
  font-size: clamp(var(--text-xl), 3vw, var(--text-2xl));
  line-height: 1;
}

.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(12rem, 14rem);
  gap: clamp(var(--space-lg), 5vw, var(--space-3xl));
  align-items: start;
  margin-left: clamp(var(--space-xs), 2.5vw, var(--space-xl));
  margin-top: var(--space-xl);
}

.post-page .post-article {
  max-width: 78ch;
}

.post-layout:not(.post-layout--with-contents) {
  grid-template-columns: minmax(0, 1fr);
  margin-left: 0;
}

.post-layout:not(.post-layout--with-contents) .post-article {
  margin-inline: auto;
}

.post-copy {
  padding-top: var(--space-lg);
  color: var(--color-ink-2);
  font-size: var(--text-base);
  line-height: 1.72;
}

.post-copy > :first-child {
  margin-top: 0;
}

.post-copy h2,
.post-copy h3 {
  margin: var(--space-lg) 0 var(--space-sm);
}

.post-copy p,
.post-copy ul,
.post-copy ol,
.post-copy blockquote,
.post-copy pre {
  margin: 0 0 var(--space-md);
}

.post-copy ul,
.post-copy ol {
  padding-left: var(--space-lg);
}

.post-copy li + li {
  margin-top: var(--space-2xs);
}

.post-copy table {
  width: 100%;
  margin: 0 0 var(--space-md);
  border: var(--rule);
  border-collapse: collapse;
  background: var(--color-surface);
  color: var(--color-ink-2);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.post-copy th,
.post-copy td {
  padding: var(--space-xs);
  border-bottom: var(--rule);
  text-align: left;
  vertical-align: top;
}

.post-copy th {
  background: var(--color-paper-2);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.post-copy tbody tr:nth-child(even) td {
  background: var(--color-paper-glass);
}

.post-copy tr:last-child td {
  border-bottom: 0;
}

.post-copy td:first-child,
.post-copy td:nth-child(2),
.post-copy td:nth-child(3),
.post-copy td:nth-child(4) {
  white-space: nowrap;
}

.post-copy .post-figure {
  max-width: 100%;
  margin: var(--space-md) 0;
}

.post-copy .post-figure img {
  display: block;
  width: 100%;
  margin: 0 auto;
}

.post-copy .post-figure figcaption,
.post-copy .wrap-image figcaption {
  margin-top: var(--space-2xs);
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.post-copy .wrap-image {
  float: right;
  width: 50%;
  margin: var(--space-3xs) 0 var(--space-sm) var(--space-md);
}

.post-copy .wrap-image[data-side="left"] {
  float: left;
  margin: var(--space-3xs) var(--space-md) var(--space-sm) 0;
}

.post-copy .wrap-image--portrait {
  width: 30%;
}

.post-copy .wrap-image img {
  display: block;
  width: 100%;
}

.post-page .post-sidebar {
  margin: 0;
  position: sticky;
  top: calc(4.25rem + var(--space-md));
}

.post-sidebar .toc-filters {
  gap: var(--space-2xs);
  margin: 0;
}

.post-sidebar .toc-filters .category-label {
  margin-bottom: var(--space-xs);
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.post-sidebar .toc-scroll {
  gap: var(--space-2xs);
  max-height: calc(100dvh - 10rem);
  padding-right: var(--space-3xs);
}

.post-sidebar .toc-filters .tag-btn {
  min-height: 2.5rem;
  padding: var(--space-2xs) 0;
  color: var(--color-ink-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.35;
  white-space: normal;
}

.post-sidebar .toc-filters .tag-btn:hover {
  color: var(--color-accent);
}

.post-nav {
  display: block;
  min-height: 0;
  width: auto;
  margin-top: var(--space-xl);
  margin-left: clamp(var(--space-md), 5vw, var(--space-3xl));
  padding: var(--space-md) 0 0;
  border-top: var(--rule);
  justify-content: normal;
}

.image-dropdown,
.music-dropdown {
  border: var(--rule);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  box-shadow: none;
}

.site-footer {
  margin-top: 0;
  border-top: var(--rule);
  background: var(--color-paper);
  text-align: left;
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 4.5rem;
  padding: 0 var(--space-md);
}

.site-footer p {
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.command-palette {
  position: fixed;
  top: clamp(5.5rem, 18vh, 10rem);
  left: 50%;
  width: min(34rem, calc(100vw - 2rem));
  max-height: min(32rem, calc(100dvh - 2rem));
  margin: 0;
  padding: 0;
  border: var(--rule);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  color: var(--color-ink);
  transform: translateX(-50%);
}

.command-palette::backdrop {
  background: var(--color-overlay);
}

.command-palette__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md);
  border-bottom: var(--rule);
}

.command-palette__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0 var(--space-xs);
  border: 0;
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.command-palette__input:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.command-palette__close {
  min-height: 2.75rem;
  border: var(--rule);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.command-palette__list {
  display: none;
  margin: 0;
}

.command-palette__list:not(:empty) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: var(--space-2xs);
  height: min(20rem, calc(100dvh - 11rem));
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: var(--space-xs);
}

.command-palette__empty {
  margin: 0;
  padding: var(--space-sm);
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.command-palette__item {
  display: block;
  flex: 0 0 auto;
  min-height: 4rem;
  padding: var(--space-sm);
  border-radius: var(--radius-control);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: normal;
}

.command-palette__item:hover,
.command-palette__item:focus-visible,
.command-palette__item.is-active {
  background: var(--color-paper-2);
  color: var(--color-accent);
}

.command-palette__item span {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.command-palette__result-title {
  display: block;
  min-width: 0;
  color: inherit !important;
  font-size: inherit !important;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.command-palette__result-type {
  display: block;
  margin-top: var(--space-2xs);
}

.command-palette__preview {
  display: block;
  margin-top: var(--space-xs);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.command-palette__preview mark {
  padding: 0 0.1em;
  background: color-mix(in oklch, var(--color-accent) 28%, transparent);
  color: inherit;
  font-weight: 600;
}

.landing-page button:active,
.landing-page a:active {
  transform: translateY(1px);
}

.landing-page button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 48rem) {
  .nav {
    min-height: 4rem;
    padding: 0 var(--space-sm);
  }

  .nav-left {
    width: auto;
  }

  .nav ul {
    top: calc(100% + 1px);
    right: 0;
    left: 0;
    gap: 0;
    padding: var(--space-xs) var(--space-md);
    border: 0;
    border-bottom: var(--rule);
    border-radius: 0;
    background: var(--color-surface);
    box-shadow: none;
  }

  .nav ul a {
    width: 100%;
  }

  .nav-command {
    padding: 0 var(--space-2xs);
  }

  .nav-actions {
    margin-left: auto;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .landing-page {
    padding: var(--space-xl) var(--space-sm) var(--space-2xl);
  }

  .about-page .about-identity h1 {
    white-space: normal;
  }

  .about-hero,
  .collection-hero,
  .blog-layout,
  .project-index .project-item,
  .post-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .collection-hero > :first-child {
    padding-left: 0;
  }

  .collection-hero {
    padding-inline: 0;
  }

  .projects-page .project-index,
  .blog-page .blog-layout,
  .fun-page .fun-stream,
  .post-layout,
  .post-nav {
    margin-left: 0;
  }

  .blog-layout {
    margin-top: var(--space-lg);
  }

  .blog-filter-panel {
    order: -1;
  }

  .tag-filters {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .tag-btn {
    width: auto;
    padding: var(--space-2xs) var(--space-xs);
    border: var(--rule);
    border-radius: var(--radius-control);
  }

  .blog-list .post-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .blog-list .post-item p {
    grid-column: auto;
  }

  .landing-list small {
    display: block;
    margin-top: var(--space-2xs);
  }

  .post-page .post-sidebar {
    margin-top: 0;
    position: static;
  }

  .post-sidebar .toc-filters .tag-btn {
    flex: 0 0 auto;
    width: auto;
    padding: var(--space-2xs) var(--space-xs);
    border: var(--rule);
    border-radius: var(--radius-control);
  }

  .post-sidebar .toc-scroll {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
    padding-right: 0;
  }

  .post-copy .wrap-image,
  .post-copy .wrap-image[data-side="left"] {
    float: none;
    width: 100%;
    margin: var(--space-md) 0;
  }

  .post-copy table {
    display: block;
    overflow-x: auto;
    white-space: normal;
  }
}

@media (max-width: 34rem) {
  .about-body {
    grid-template-areas:
      "copy"
      "portrait";
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .landing-page *,
  .landing-page *::before,
  .landing-page *::after {
    transition-duration: 0ms !important;
  }
}
