:root{
  --bg: #000000;          /* pure black */
  --fg: #fdfccf;          /* cream */
  --muted: #d6d5a6;
  --accent: #c8c79a;      /* subtle borders/underlines */
  --maxw: 760px;
  --sidebar: 120px;
  --content-pad: 24px;
  --widget-rail-desktop: 240px;
  --widget-rail-laptop: 188px;
  --widget-rail: var(--widget-rail-desktop);
  --widget-panel-min: 164px;
  --widget-panel-max: 220px;
  --spotify-panel-max: 320px;
}

*{
  box-sizing:border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
html,body{ height:100%; width:100%; }
html{
  scroll-behavior:smooth;
  scrollbar-gutter: stable;
  overflow-y: scroll;
}

body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font: 18px/1.7 "STIX Two Text", ui-serif, Georgia, "Times New Roman", Times, serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-user-select: none;
}

#liquid-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.06;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 0;
  display: block;
  touch-action: none;
  border: none;
  outline: none;
  background: transparent;
}

.home-container,
.main,
.content-blur-wrap {
  position: relative;
  z-index: 1;
}

.content-blur-wrap {
  transition: opacity 0.3s ease;
}

.content-blur-wrap {
  position: relative;
}

body.home .content-blur-wrap {
  height: 100dvh;
  min-height: 100dvh;
  overflow: clip;
}

.content-blur-wrap::before,
.content-blur-wrap::after {
  content: '';
  position: fixed;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  height: 160px;
  pointer-events: none;
  z-index: 4;
  transition: opacity 0.4s ease;
}

.content-blur-wrap::before {
  top: 0;
  background: linear-gradient(to bottom, var(--bg) 0%, transparent 100%);
  opacity: var(--blur-top, 0);
}

.content-blur-wrap::after {
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 100%);
  opacity: var(--blur-bottom, 0);
}

@media (max-width: 900px), (pointer: coarse) {
  .content-blur-wrap::before,
  .content-blur-wrap::after {
    opacity: 0 !important;
  }
}

/* Sidebar nav (chen.pw vibes) */
.nav{
  position:fixed;
  top:26px; left:26px;
  width:var(--sidebar);
  display:flex; flex-direction:column; gap:8px;
  z-index:5;
}
.nav a{
  color:var(--fg);
  text-decoration:none;
  opacity:.85;
  font-size:14px;
}
.nav a:hover{ opacity:1; font-style:italic; text-decoration:none; }
.nav a.active{ opacity:1; font-weight:700; text-decoration:none; }

/* Main column */
.main{
  max-width:var(--maxw);
  width: min(var(--maxw), calc(100% - (2 * var(--widget-rail)) - (2 * var(--content-pad))));
  margin: 56px auto 96px;
  padding: 0 var(--content-pad);
}

h1,h2,h3{ line-height:1.25; margin:1.2em 0 .45em; }
h1{ font-size:34px; border-bottom:2px solid var(--accent); padding-bottom:.35em; }
h2{ font-size:24px; margin-top:1.6em; }
h3{ font-size:20px; }
p,li{ color:var(--fg); }
p.muted,.muted{ color:var(--muted); }

p, h1, h2, h3, h4, li, td, th, code, pre, blockquote, .selectable {
  user-select: text;
  -webkit-user-select: text;
}

a{ color:var(--fg); text-decoration: none; }
a:hover{ font-style:italic; text-decoration:none; }
hr{ border:none; border-top:1px solid var(--accent); margin:24px 0; }

/* Home splash */
.logo-wrap{
  min-height:calc(100vh - 120px);
  display:grid; place-items:center;
}
.logo{ width:min(28vw, 280px); height:auto; }

/* Lists (blog/portfolio) */
.item{ margin: 26px 0 32px; }
.item h3{ margin:0 0 6px; font-size:20px; }
.item .dek{ font-style:italic; color:var(--muted); margin:0 0 8px; }
.item .meta{ font-size:14px; }

/* Portfolio expand/collapse sections */
.expandable{
  padding-top: 0;
  margin-top: 20px;
}

.expandable-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}

.expandable-head h2{
  margin:0;
}

.expand-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:22px;
  height:22px;
  padding:0;
  border:none;
  background:none;
  color:var(--fg);
  cursor:pointer;
  transition: opacity .2s ease;
}

.expand-btn:hover{ opacity:.8; }

.expand-icon{
  position:relative;
  display:block;
  width:14px;
  height:14px;
  transform: rotate(0deg);
  transition: transform .28s ease;
}

.expand-icon::before,
.expand-icon::after{
  content:"";
  position:absolute;
  top:50%;
  left:50%;
  width:14px;
  height:1.5px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.expand-icon::after{
  transform: translate(-50%, -50%) rotate(90deg);
}

.expand-btn[aria-expanded="true"] .expand-icon{
  transform: rotate(45deg);
}

.expandable-panel{
  margin-top: 12px;
  overflow:hidden;
  max-height:0;
  opacity:0;
  transition:max-height .34s ease, opacity .24s ease;
}

.expandable-panel.is-open{
  opacity:1;
}

.expandable-panel h3{
  margin-top: 1.4em;
  font-size: 17px;
}

.expandable-panel h3:first-child{
  margin-top: 4px;
}

/* Portfolio / research cards */
.portfolio-card{
  display:flex;
  gap:16px;
  align-items:flex-start;
  margin: 14px 0;
  padding-top: 14px;
  border-top: 1px solid #1e1e1e;
}

.portfolio-card:first-of-type{
  border-top:none;
  padding-top:0;
}

.portfolio-thumb-link{
  flex-shrink:0;
  text-decoration:none;
}

/* Image thumbnails (e.g. GitHub OG card) */
.portfolio-thumb{
  width:148px;
  height:76px;
  overflow:hidden;
  border:none;
  border-radius:8px;
  background:transparent;
}

.portfolio-thumb img{
  width:100%;
  height:100%;
  object-fit:contain;
  object-position:center;
  border-radius:8px;
  display:block;
}

/* PDF first-page thumbnail via scaled-down iframe */
.pdf-thumb{
  width:148px;
  height:76px;
  overflow:hidden;
  border:none;
  border-radius:8px;
  background:#0d0d0d;
  position:relative;
}

.pdf-thumb iframe{
  width:816px;        /* browser default PDF viewport width */
  height:1056px;      /* US-letter height at 96dpi */
  transform:scale(0.1814);   /* 148 / 816 ≈ 0.1814 to match thumbnail width */
  transform-origin:0 0;
  pointer-events:none;
  border:none;
}

.portfolio-card-body{
  flex:1;
  min-width:0;
}

.portfolio-card-title{
  font-weight:600;
  font-size:15px;
  margin-bottom:3px;
  color:var(--fg);
}

.portfolio-card-meta{
  font-size:13px;
  color:var(--muted);
  margin:0 0 8px;
}

.portfolio-card-desc{
  font-size:14px;
  line-height:1.55;
  margin:0 0 10px;
  color:var(--fg);
}

/* "learn more" / "view poster" link inside a card */
.portfolio-learn-more{
  font-size:13px;
  color:var(--fg);
  text-decoration:none;
  opacity:.75;
}

.portfolio-learn-more:hover{
  opacity:1;
  font-style:italic;
  text-decoration:none;
}

/* Patent cards */
.patent-card{
  margin:14px 0;
  padding-top:14px;
  border-top:1px solid #1e1e1e;
}

.patent-card:first-of-type{
  border-top:none;
  padding-top:0;
}

.patent-card-title{
  font-weight:600;
  font-size:15px;
  margin-bottom:4px;
  color:var(--fg);
}

.patent-card-meta{
  font-size:13px;
  color:var(--muted);
  margin:0 0 8px;
}

.patent-card-desc{
  font-size:14px;
  line-height:1.55;
  color:var(--fg);
  margin:0;
}

/* Optional avatar on research */
.avatar{
  float:right; width:132px; height:132px; border-radius:999px;
  object-fit:cover; margin-left:18px; border:2px solid var(--accent);
}

/* Tables / code (if you ever need them) */
table{ width:100%; border-collapse:collapse; margin:16px 0; }
th,td{ border-bottom:1px solid var(--accent); padding:8px 6px; text-align:left; }
code,pre{ background:#0a0a0a; border:1px solid #161616; color:var(--fg); }
code{ padding:2px 6px; border-radius:4px; }
pre{ padding:12px 14px; border-radius:6px; overflow:auto; }

/* Mobile */
@media (max-width: 860px){
  .nav{ position:static; width:auto; padding:16px 24px 0; flex-direction:row; gap:16px; }
  .main{ margin-top:12px; }
  .avatar{ float:none; margin:0 0 12px; display:block; }
}

/* === universal colors === */
:root {
  --bg: #000000;
  --fg: #fdfccf;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "STIX Two Text", serif;
  margin: 0;
  padding: 0;
}

/* === home page layout === */
.home-container {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: min(var(--maxw), calc(100% - (2 * var(--widget-rail)) - (2 * var(--content-pad))));
  padding: 24px var(--content-pad);
  gap: 0;
  margin: 0 auto;
}

/* === home logo === */
.home-logo {
  width: min(50vw, 10000px);
  height: auto;
  display: block;
  filter: none;
  margin-bottom: 0;
}

.home-nav {
  position: fixed;
  bottom: 3vh;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2rem;
  justify-content: center;
  font-size: 1.15rem;
  white-space: nowrap;
  z-index: 5;
}

.home-nav a {
  color: var(--fg);
  text-decoration: none;
  transition: opacity 0.2s;
}

.home-nav a:hover {
  opacity: 0.7;
  font-style: italic;
  text-decoration: none;
}

/* Centered container for selected pages (keeps inner text left-aligned) */
.page-centered .main {
  min-height: 100vh;
  margin: 0 auto;            /* keep column centered horizontally */
  display: flex;
  flex-direction: column;
  justify-content: center;   /* vertical centering */
}

/* Blog post pages: use body class="blog-post" for centered post layout. */
.blog-post .main {
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Portrait image on research page (right-floated, text wraps on left) */
.portrait {
  float: right;
  width: 160px;
  height: 160px;
  object-fit: cover;
  margin: 0 0 8px 16px;
  border: none;
  border-radius: 0;
}

@media (max-width: 860px){
  /* allow some room for mobile UI while keeping center intent */
  .page-centered .main { min-height: calc(100vh - 32px); }
  .blog-post .main { min-height: calc(100vh - 32px); }
  .portrait { float: none; display: block; margin: 0 auto 12px; }
  .home-nav {
    gap: 1.4rem;
    font-size: 1.05rem;
    bottom: 4vh;
  }
  .home-logo {
    width: min(72vw, 10000px);
  }
}

/* ── Widget pod: the positioning wrapper for each widget ── */
.widget-pod {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  overflow: visible;
}

/* Left pods: anchored to left edge */
.widget-pod--left {
  left: 0;
  width: var(--widget-rail);
}

/* Right pods: anchored to right edge */
.widget-pod--right {
  right: 0;
  width: var(--widget-rail);
}

/* Bottom pod: anchored to bottom center */
.widget-pod--bottom {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
}

@keyframes haze-breathe {
  0%, 100% { opacity: 0.75; }
  50%       { opacity: 0.25; }
}

/* ── Haze cloud ── */
.widget-haze {
  position: absolute;
  border-radius: 9999px;
  background: radial-gradient(ellipse at center,
    rgba(253, 252, 207, 0.35) 0%,
    rgba(253, 252, 207, 0.12) 40%,
    transparent 70%
  );
  filter: blur(16px);
  transition: opacity 0.5s ease, width 0.5s ease, height 0.5s ease,
              transform 0.5s ease;
  opacity: 0.75;
  pointer-events: auto;
  cursor: default;
  animation: haze-breathe 3s ease-in-out infinite;
  animation-play-state: running;
}

/* Left haze: vertical oval on the left edge */
.widget-haze--left {
  left: -35px;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 160px;
}

/* Right haze: vertical oval on the right edge */
.widget-haze--right {
  right: -35px;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 160px;
}

/* Bottom haze: horizontal oval on the bottom edge */
.widget-haze--bottom {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 56px;
}

.widget-pod.is-revealed .widget-haze {
  animation: none;
  opacity: 0;
}

/* Left haze explodes rightward and fades out on reveal */
.widget-pod.is-revealed .widget-haze--left {
  opacity: 0;
  width: 160px;
  height: 300px;
  transform: translateY(-50%) translateX(40px);
}

/* Right haze explodes leftward and fades out on reveal */
.widget-pod.is-revealed .widget-haze--right {
  opacity: 0;
  width: 160px;
  height: 300px;
  transform: translateY(-50%) translateX(-40px);
}

/* Bottom haze explodes upward and fades out on reveal */
.widget-pod.is-revealed .widget-haze--bottom {
  opacity: 0;
  width: 320px;
  height: 160px;
  transform: translateX(-50%) translateY(-40px);
}

/* ── Widget panel: the actual content card ── */
.widget-panel {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  background: rgba(6, 6, 4, 0.88);
  border: 1px solid rgba(253, 252, 207, 0.08);
  border-radius: 4px;
  padding: 12px 14px;
  width: clamp(var(--widget-panel-min), 18vw, var(--widget-panel-max));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* Left panels: sit just off screen to the left, slide right on reveal */
.widget-panel--left {
  left: 14px;
  top: 50%;
  transform: translateY(-50%) translateX(-24px);
}

/* Right panels: sit just off screen to the right, slide left on reveal */
.widget-panel--right {
  right: 14px;
  top: 50%;
  transform: translateY(-50%) translateX(24px);
}

/* Bottom panel: sits below screen, slides up on reveal */
.widget-panel--bottom {
  bottom: 4px;
  left: 50%;
  width: auto;
  white-space: nowrap;
  transform: translateX(-50%) translateY(24px);
}

/* Revealed panel states */
.widget-pod.is-revealed .widget-panel--left {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}
.widget-pod.is-revealed .widget-panel--right {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}
.widget-pod.is-revealed .widget-panel--bottom {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* ── Widget internals ── */
.widget-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}

.widget-text {
  font-size: 12px;
  color: var(--fg);
  line-height: 1.5;
}

.widget-bar {
  margin-top: 8px;
  height: 2px;
  background: rgba(253, 252, 207, 0.1);
  border-radius: 1px;
  overflow: hidden;
}
.widget-bar-fill {
  height: 100%;
  background: var(--muted);
  border-radius: 1px;
  transition: width 0.6s ease;
}

/* Nav widget links */
.widget-nav-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.widget-nav-links a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  font-style: italic;
  transition: color 0.2s;
}
.widget-nav-links a:hover  { color: var(--fg); }
.widget-nav-links a.active { color: var(--fg); font-weight: 700; }

#wp-nav .widget-panel {
  background: transparent;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
  width: auto;
}

#wp-nav .widget-nav-links a {
  font-size: 14px;
  color: var(--fg);
  opacity: 0.85;
  font-style: normal;
}

#wp-nav .widget-nav-links a:hover {
  opacity: 1;
  font-style: italic;
}

#wp-nav .widget-nav-links a.active {
  opacity: 1;
  font-weight: 700;
}

#wp-nav {
  display: none !important;
}

#wp-nav .widget-panel--left {
  left: 26px;
  top: 0;
  transform: translateX(-16px);
}

#wp-nav.is-revealed .widget-panel--left {
  transform: translateX(0);
}

/* Home nav widget links */
.widget-homenav-links {
  display: flex;
  gap: 2rem;
  padding: 10px 16px;
}
.widget-homenav-links a {
  font-size: 1.05rem;
  color: var(--muted);
  text-decoration: none;
  font-style: italic;
  transition: color 0.2s;
}
.widget-homenav-links a:hover { color: var(--fg); }

#wp-homenav .widget-panel {
  background: transparent;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
  width: auto;
  white-space: nowrap;
}

#wp-homenav .widget-homenav-links a {
  font-size: 1.15rem;
  color: var(--fg);
  font-style: normal;
  opacity: 0.85;
}

#wp-homenav .widget-homenav-links a:hover {
  opacity: 0.7;
  font-style: italic;
}

#wp-homenav {
  display: none !important;
}

#wp-homenav .widget-haze--bottom {
  bottom: calc(6vh + 20px);
}

#wp-homenav .widget-panel--bottom {
  bottom: calc(6vh);
  transform: translateX(-50%) translateY(16px);
}

#wp-homenav.is-revealed .widget-panel--bottom {
  transform: translateX(-50%) translateY(0);
}

#wp-spotify .widget-haze  { animation-delay: 0s; }
#wp-github .widget-haze   { animation-delay: 0.75s; }
#wp-updates .widget-haze  { animation-delay: 1.5s; }
#wp-reading .widget-haze  { animation-delay: 2.25s; }
#wp-spotify .widget-panel {
  width: clamp(220px, 28vw, var(--spotify-panel-max));
}

#wp-spotify .widget-panel iframe {
  height: clamp(72px, 9vw, 96px);
}

/* Laptop + scaled desktop: narrow rails, slightly tighter cards, hide heavy Spotify pod */
@media (max-width: 1320px) {
  :root {
    --widget-rail: 210px;
    --widget-panel-max: 188px;
    --spotify-panel-max: 240px;
    --content-pad: 20px;
  }

  #wp-spotify {
    display: block;
  }

  #wp-spotify .widget-panel {
    width: clamp(168px, 20vw, 220px);
  }

  #wp-spotify .widget-panel iframe {
    height: clamp(70px, 6.5vw, 84px);
  }
}

/* Tablet + mobile: content-first layout with bottom dock only */
@media (max-width: 1024px), (pointer: coarse) {
  :root {
    --widget-rail: 0px;
    --content-pad: 18px;
  }

  #liquid-canvas {
    display: none !important;
  }

  .widget-pod {
    display: none !important;
  }

  .main,
  .home-container,
  .page-centered .main,
  .blog-post .main {
    width: min(var(--maxw), 100vw);
    max-width: var(--maxw);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--content-pad);
    padding-right: var(--content-pad);
  }

  .home-container {
    min-height: calc(100dvh - 64px);
  }
}

/* GitHub grid */
.github-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 2px;
  margin-top: 4px;
}
.github-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: rgba(253, 252, 207, 0.06);
}
.github-cell[data-level="1"] { background: rgba(253, 252, 207, 0.15); }
.github-cell[data-level="2"] { background: rgba(253, 252, 207, 0.30); }
.github-cell[data-level="3"] { background: rgba(253, 252, 207, 0.50); }
.github-cell[data-level="4"] { background: rgba(253, 252, 207, 0.75); }

/* Spotify iframe */
.widget-panel iframe {
  border-radius: 4px;
  margin-top: 4px;
  display: block;
  filter: grayscale(0.3) brightness(0.85);
}

/* Mobile */
@media (hover: none) {
  .widget-pod { pointer-events: auto; }
}

