/* haoagent.top design system - editorial serif archetype */
:root {
  --bg: #1b1a19;
  --foreground: #ece7e1;
  --text-copy: #e8e5df;
  --text-heading: #f5f2eb;
  --text-secondary: #cbc6be;
  --text-nav: #a6a199;
  --surface-subtle: #242321;
  --divider: #3b3936;
  --line-subtle: rgba(236, 231, 225, 0.14);
  --focus-color: #c5a53f;
  --page-pad: clamp(1.25rem, 3.5vw, 3.25rem);
  --content-width: 640px;
  --font-reading: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Songti SC", "SimSun", serif;
  --font-ui: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text-copy);
  font-family: var(--font-reading);
  font-size: 17px;
  line-height: 1.68;
  letter-spacing: normal;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(236, 231, 225, 0.16);
}

/* Hyperlinks: Fix default browser blue, match muted editorial palette */
a,
a:link,
a:visited {
  color: var(--text-copy);
  text-decoration: underline;
  text-decoration-color: rgba(236, 231, 225, 0.28);
  text-decoration-skip-ink: auto;
  text-underline-offset: 0.2em;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

a:hover,
a:link:hover,
a:visited:hover {
  color: #ffffff;
  text-decoration-color: rgba(255, 255, 255, 0.65);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 3px;
  border-radius: 2px;
}

.site-shell {
  min-height: 100vh;
  padding: var(--page-pad);
}

.content-frame {
  position: relative;
  width: min(100%, 1280px);
  margin-inline: auto;
  min-width: 0;
  overflow-wrap: break-word;
}

/* Two-column layout: Main Copy on Left, Visual on Right (matching leerob.com) */
.home-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 440px);
  gap: clamp(2.5rem, 4.5vw, 4.75rem);
  align-items: start;
  min-width: 0;
}

/* Sticky Visual Card on Desktop */
.home-visual {
  position: sticky;
  top: var(--page-pad);
  display: block;
  height: min(780px, calc(100svh - (2 * var(--page-pad))));
  min-height: 520px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid rgba(236, 231, 225, 0.1);
  border-radius: 14px;
  background: var(--surface-subtle);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.55);
  isolation: isolate;
}

.painting-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.painting-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  transform: translateZ(0);
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.painting-card:hover .painting-image {
  transform: scale(1.025);
}

.painting-card.is-avatar-active:hover .painting-image {
  transform: translateZ(0);
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.14;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.28 0 0 0 0 0.2 -2.6 0 0 0 1.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* 3D Virtual Avatar Overlay inside Landscape Card */
.avatar-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.28s ease;
  touch-action: pan-y;
}

.painting-card.is-avatar-ready.is-avatar-active .avatar-stage {
  opacity: 1;
}

.painting-card:not(.is-avatar-active) .avatar-stage {
  pointer-events: none;
}

.avatar-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.avatar-canvas.is-dragging {
  cursor: grabbing;
}

.avatar-fallback-img {
  position: absolute;
  left: 50%;
  bottom: 4%;
  height: 78%;
  width: auto;
  transform: translateX(-50%);
  pointer-events: none;
}

.avatar-sparkle {
  position: absolute;
  z-index: 3;
  color: var(--focus-color);
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  animation: sparkleFloat 0.78s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sparkleFloat {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.4) rotate(0deg); }
  25% { opacity: 0.95; transform: translate(-50%, -10px) scale(1.05) rotate(12deg); }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(0.7) rotate(28deg); }
}

.visual-controls {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.visual-pill {
  padding: 0.28rem 0.62rem;
  border: 1px solid rgba(236, 231, 225, 0.22);
  border-radius: 999px;
  background: rgba(27, 26, 25, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-copy);
  font-family: var(--font-ui);
  font-size: 11.5px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.visual-pill:hover {
  background: rgba(27, 26, 25, 0.84);
  border-color: rgba(236, 231, 225, 0.42);
  color: #ffffff;
}

.visual-pill[aria-pressed="false"] {
  color: var(--text-nav);
}

.avatar-loading {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid rgba(236, 231, 225, 0.18);
  border-radius: 999px;
  background: rgba(27, 26, 25, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 11.5px;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.avatar-loading.is-hidden {
  opacity: 0;
}

.avatar-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--focus-color);
  animation: avatarPulse 1.2s ease-in-out infinite;
}

@keyframes avatarPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.avatar-bubble {
  position: absolute;
  top: 3.1rem;
  left: 0.85rem;
  right: 0.85rem;
  z-index: 4;
  max-width: min(300px, calc(100% - 1.7rem));
  margin-inline: auto;
  padding: 0.58rem 0.85rem;
  border: 1px solid rgba(236, 231, 225, 0.2);
  border-radius: 10px;
  background: rgba(27, 26, 25, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.36);
  color: var(--text-heading);
  font-family: var(--font-ui);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
  animation: bubbleIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Reading Column */
.home-copy {
  position: relative;
  z-index: 1;
  width: min(100%, var(--content-width));
  min-width: 0;
}

.site-title {
  margin: 0 0 0.95em;
  color: var(--text-heading);
  font-family: var(--font-reading);
  font-size: clamp(2.2rem, 3.5vw, 2.75rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.site-title-link,
.site-title-link:link,
.site-title-link:visited {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s;
}

.site-title-link:hover,
.site-title-link:link:hover {
  color: inherit;
  opacity: 0.75;
}

.bio-section {
  margin-bottom: 3.25rem;
}

.bio-toggle {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.35rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line-subtle);
  color: var(--text-nav);
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.bio-toggle-label {
  color: var(--text-nav);
  font-weight: 500;
}

.bio-toggle-options {
  display: flex;
  gap: 1.15rem;
  margin-left: auto;
}

.bio-toggle button {
  position: relative;
  padding: 0 0 0.25rem;
  border: 0;
  color: var(--text-nav);
  font: inherit;
  font-size: 13.5px;
  background: transparent;
  cursor: pointer;
  transition: color 0.16s ease;
}

.bio-toggle button:hover {
  color: var(--text-copy);
}

.bio-toggle button[aria-pressed="true"] {
  color: var(--text-heading);
}

.bio-toggle button[aria-pressed="true"]::after {
  position: absolute;
  right: 0;
  bottom: -0.62rem;
  left: 0;
  height: 1.5px;
  background: var(--text-heading);
  content: "";
}

.content-paragraph {
  margin: 0 0 1.35rem;
  text-wrap: pretty;
}

.bio-detail-list {
  margin: 0 0 1.4rem;
  padding-left: 1.25rem;
  list-style: square;
}

.bio-detail-list li {
  margin-bottom: 0.75rem;
  color: var(--text-copy);
  font-size: 16px;
  line-height: 1.65;
}

.bio-detail-list strong {
  color: var(--text-heading);
  font-weight: 600;
}

.writing-index,
.writing-index > section + section {
  margin-top: 3.5rem;
}

.writing-index h2 {
  margin: 0;
  color: var(--text-heading);
  font-family: var(--font-reading);
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.blogs-list {
  margin-top: 0.85em;
  border-top: 1px solid var(--line-subtle);
}

.blog-row,
.blog-row:link,
.blog-row:visited {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.85em 0;
  border-bottom: 1px solid var(--line-subtle);
  color: var(--text-copy);
  text-decoration: none;
}

.project-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.project-name {
  color: var(--text-heading);
  font-weight: 550;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.project-desc {
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.4;
}

a.blog-row:hover,
a.blog-row:link:hover {
  color: var(--text-copy);
}

@media (hover: hover) and (pointer: fine) {
  .blog-row {
    transition: opacity 0.25s ease-in-out;
  }

  .blogs-list:hover .blog-row {
    opacity: 0.72;
  }

  .blogs-list:hover .blog-row:hover {
    opacity: 1;
  }
}

.blog-row time {
  color: var(--text-nav);
  font-family: var(--font-ui);
  font-size: 14px;
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}

/* Servers Section */
.servers {
  margin-top: 3.5rem;
}

.section-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading-row h2 {
  margin: 0;
}

.subtle-link,
.subtle-link:link,
.subtle-link:visited {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-nav);
  text-decoration: none;
}

.subtle-link:hover,
.subtle-link:link:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

.server-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 0.85em;
  min-width: 0;
}

.server-card {
  min-width: 0;
  padding: 1.15rem 1.2rem 1.05rem;
  border: 1px solid var(--line-subtle);
  border-radius: 8px;
  background: rgba(36, 35, 33, 0.75);
}

.server-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.05rem;
}

.server-id {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.server-card h3 {
  margin: 0;
  color: var(--text-heading);
  font-family: var(--font-ui);
  font-size: 0.96rem;
  font-weight: 650;
}

.role-tag {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-nav);
  background: rgba(236, 231, 225, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(236, 231, 225, 0.08);
}

.server-card .status {
  color: #8ba67f;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.server-card .status::before {
  display: inline-block;
  width: 0.4em;
  height: 0.4em;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
  content: "";
}

.server-card dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0;
}

.server-card .metric {
  min-width: 0;
}

.server-card .metric-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.server-card dt {
  color: var(--text-nav);
  font-family: var(--font-ui);
  font-size: 0.74rem;
}

.server-card dd {
  margin: 0;
  color: var(--text-copy);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.server-card .bar {
  height: 4px;
  margin-top: 0.55rem;
  overflow: hidden;
  background: rgba(236, 231, 225, 0.12);
  border-radius: 999px;
}

.server-card .bar span {
  display: block;
  width: var(--value);
  height: 100%;
  background: #9d8b5a;
}

.server-card small {
  display: block;
  margin-top: 0.42rem;
  color: var(--text-nav);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  line-height: 1.3;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2.5rem var(--page-pad) 2.2rem;
  border-top: 1px solid var(--divider);
  color: var(--text-nav);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

/* Tablet & Mobile Responsiveness */
@media (max-width: 1024px) {
  .home-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
  }

  .home-copy {
    display: contents;
  }

  .bio-section {
    order: 1;
    margin-bottom: 0;
  }

  .home-visual {
    order: 2;
    position: relative;
    top: 0;
    width: 100%;
    height: 340px;
    min-height: 300px;
    border-radius: 12px;
    margin: 0.5rem 0 1rem;
  }

  .painting-image {
    object-position: center 35%;
  }

  .writing-index {
    order: 3;
    margin-top: 1rem;
  }

  .servers {
    order: 4;
    margin-top: 2.5rem;
  }
}

@media (max-width: 639px) {
  .site-shell {
    padding: 1.5rem 1.15rem 1.5rem;
  }

  .home-visual {
    height: 280px;
    min-height: 260px;
    border-radius: 10px;
    margin: 0.25rem 0 0.75rem;
  }

  .painting-image {
    object-position: center 35%;
  }

  .bio-toggle {
    margin-bottom: 1.15rem;
  }

  .blog-row,
  .blog-row:link,
  .blog-row:visited {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .blog-row time {
    font-size: 13px;
  }

  .server-grid {
    grid-template-columns: 1fr;
  }

  .server-card dl {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
