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

:root {
  --bg:     #212738;   /* page — deep navy */
  --ink:    #f5f5f7;   /* primary text     */
  --muted:  #a3a8b8;   /* secondary        */
  --faint:  #737a8c;   /* tertiary         */
  --accent: #ffba08;   /* amber — nav hover, matches the avatar badge */
  --line:   rgba(255,255,255,0.11);
  --field:  rgba(255,255,255,0.06);
  --field-focus: rgba(255,255,255,0.1);
  --glass-bg:     rgba(45,53,76,0.55);
  --glass-border: rgba(255,255,255,0.12);
  --glass-shadow: 0 12px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
/* the sticky nav would otherwise cover the top of a jumped-to section */
#videos,
#research { scroll-margin-top: 110px; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;   /* safety net against horizontal scroll */
}

/* ── Top navigation (sticks to the top of the viewport) ── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(33, 39, 56, 0.82);   /* --bg at 82% */
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
/* no blur support → solid bar, so content can't show through */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-nav { background: var(--bg); }
}

/* 1fr | auto | 1fr keeps the links centred on the page, not between the
   brand and the button (whose widths differ) */
.nav-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0.85rem 1.75rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.5rem;
}
.nav-brand { justify-self: start; display: block; }

.nav-links {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 1.75rem;
  font-size: 0.95rem;
  white-space: nowrap;
}
.nav-links a {
  color: var(--muted);
  letter-spacing: -0.01em;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}
.nav-links a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.nav-cv { justify-self: end; }

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 3.25rem 1.75rem 6rem;
}

/* min-width:0 stops the no-wrap logo row / long words from forcing
   the column (and the page) wider than the viewport on mobile */
.hero,
.content { min-width: 0; }

/* ── Hero ── */
.hero {
  max-width: 660px;
  margin: 0 auto 5rem;
}

/* the chips are absolutely positioned against this box */
.hero-photo {
  position: relative;
  width: 224px;
  height: 224px;
  margin: 0 auto 2.75rem;
}
.hero-photo img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.float-chip {
  position: absolute;
  padding: 0.42rem 0.95rem;
  border-radius: 4px;          /* just off sharp */
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0,0,0,0.35);
  animation: chip-float 5s ease-in-out infinite;
}
.chip-educator {
  background: #3f88c5;
  color: #fff;
  top: 4%;
  left: -32%;
  animation-delay: 0s;
}
.chip-programmer {
  background: #edf2ef;
  color: var(--bg);
  top: 44%;
  right: -38%;
  animation-delay: 1.6s;
}
.chip-engineer {
  background: var(--accent);
  color: var(--bg);
  bottom: 2%;
  left: -28%;
  animation-delay: 3.2s;
}
@keyframes chip-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}
@media (prefers-reduced-motion: reduce) {
  .float-chip { animation: none; }
  /* mobile nav swap snaps instead of sliding */
  .nav-brand,
  .nav-cv,
  .nav-links { transition: none; }
}

/* ── Header ── */
.header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.25rem;
}
.header-row .ai-ask { flex: 1; min-width: 0; margin-top: 0; }

.avatar {
  display: block;
  width: 59px;
  height: 59px;
  border-radius: 50%;
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.intro-title {
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-align: center;
  margin: 2.5rem 0 1.25rem;
}

/* ── Intro video (boxed, matches card styling) ── */
.intro-video {
  width: 100%;
  margin: 0 0 1.4rem;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--field);
  box-shadow: var(--glass-shadow);
}
.intro-video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.intro p {
  color: #fff;
  margin-bottom: 1.15rem;
}
.intro p:last-child { margin-bottom: 0; }
.intro strong { color: var(--ink); font-weight: 600; }

a { color: inherit; text-decoration: none; }
.intro a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}
.intro a:hover { text-decoration-color: var(--ink); }

/* ── Download CV button ── */
.cv-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.55rem 1.05rem;
  border: 1px solid var(--ink);
  border-radius: 100px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.cv-btn svg { stroke-width: 2; }
/* amber fill with page-coloured text on hover/press, so the label stays legible */
.cv-btn:hover,
.cv-btn:active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.cv-btn:active { transform: scale(0.97); }

/* ── Tutorial videos (auto-scrolling strip) ── */
.videos {
  margin-top: 2.25rem;
}

.videos-head {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}
.videos-head .section-label { margin-bottom: 0; }
/* label keeps the left rail; the channel link sits centred above the strip */
.videos-head .yt-btn { align-self: center; }

/* YouTube mark + label — the logo carries the red, so the link stays plain */
.yt-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: opacity 0.18s, transform 0.15s;
}
.yt-logo {
  height: 26px;
  width: auto;
  display: block;
  flex-shrink: 0;
  transition: transform 0.18s;
}
.yt-btn:hover .yt-logo { transform: scale(1.08); }
.yt-btn:active { transform: scale(0.98); }

/* feathered edges — thumbnails fade out into the page instead of being
   cut off, so the loop has no hard seam at either end */
.marquee {
  overflow: hidden;
  --feather: 72px;
  -webkit-mask-image: linear-gradient(to right,
    transparent 0, #000 var(--feather),
    #000 calc(100% - var(--feather)), transparent 100%);
  mask-image: linear-gradient(to right,
    transparent 0, #000 var(--feather),
    #000 calc(100% - var(--feather)), transparent 100%);
}
.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee-scroll 26s linear infinite;
}
/* the trailing margin belongs to the group (not a track gap) so one group's
   width is exactly half the track — otherwise the loop jumps by one gap */
.marquee-group {
  display: flex;
  gap: 0.75rem;
  margin-right: 0.75rem;
}
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
/* hold on hover/focus, and for good once a video is actually playing */
.marquee:hover .marquee-track,
.marquee:focus-within .marquee-track,
.marquee-track.is-paused {
  animation-play-state: paused;
}
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
  .marquee { overflow-x: auto; }
}

.marquee .video-embed {
  flex: none;
  width: 268px;
}

.video-embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--field);
  box-shadow: var(--glass-shadow);
}
.video-embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Clickable thumbnail (facade) shown before the player loads */
.video-facade {
  position: relative;
  display: block;
  padding: 0;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.video-facade .video-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-facade .video-thumb { transition: opacity 0.2s; }
.video-facade:hover .video-thumb,
.video-facade:focus-visible .video-thumb { opacity: 0.82; }

/* ── Footer ── */
.site-footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 2.5rem 1.75rem 3rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--faint);
  letter-spacing: -0.01em;
}
.site-footer .heart {
  color: #ff5a5f;
  font-style: normal;
}

/* ── Section label ── */
.section-label {
  font-size: 0.95rem;
  color: var(--faint);
  margin-bottom: 1.1rem;
  letter-spacing: -0.01em;
}

/* ── AI assistant (subtle) ── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.search-wrap:focus-within {
  border-color: var(--ink);
  background: var(--field-focus);
  box-shadow: 0 1px 10px rgba(0,0,0,0.25);
}

/* shake nudge kept, glow toned down to monochrome */
@keyframes nudge-shake {
  0%, 100% { transform: translateX(0); }
  12% { transform: translateX(-6px); }
  25% { transform: translateX(6px); }
  37% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  62% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
  87% { transform: translateX(-1px); }
}
@keyframes nudge-glow {
  0%, 100% { border-color: var(--line); box-shadow: none; }
  50% { border-color: rgba(255,255,255,0.42); box-shadow: 0 0 0 3px rgba(255,255,255,0.07); }
}
.search-wrap.nudge {
  animation: nudge-shake 0.6s cubic-bezier(0.36,0.07,0.19,0.97) 1,
             nudge-glow 1.6s ease-in-out 0.6s 1;
}
.search-wrap.island-pop { animation: pop 0.4s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes pop { 0%{transform:scale(1);} 40%{transform:scale(1.012);} 100%{transform:scale(1);} }

#question {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 0.85rem 0 0.85rem 1rem;
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
  letter-spacing: -0.01em;
  outline: none;
}
#question::placeholder { color: var(--faint); }

/* magic typewriter hint */
.magic-hint {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 1px;
  pointer-events: none;
}
#magic-text {
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--faint);
}
.magic-cursor {
  width: 1.5px;
  height: 1em;
  background: var(--faint);
  border-radius: 1px;
  animation: cursor-blink 1s step-end infinite;
  flex-shrink: 0;
}
@keyframes cursor-blink { 0%,100%{opacity:1;} 50%{opacity:0;} }

/* ── Response panel (glassy, floats over content) ── */
/* narrow rail, centred in the hero — the response panel is pinned to this
   box's edges, so it keeps the same width as the input */
.head-wrap {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
}

#response-area {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.7rem;
  z-index: 50;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  max-height: 50vh;
  animation: panel-in 0.22s cubic-bezier(0.16,1,0.3,1);
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.response-card {
  overflow-y: auto;
  flex: 1;
  padding: 1.15rem 1.3rem;
  font-size: 0.96rem;
  line-height: 1.68;
  color: var(--muted);
  text-align: left;
  overscroll-behavior: contain;
}
.response-card::-webkit-scrollbar { width: 4px; }
.response-card::-webkit-scrollbar-track { background: transparent; }
.response-card::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.22); border-radius: 2px; }
.response-card strong { color: var(--ink); }
.response-card a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-word;
}
.response-card.error { color: #d70015; }

.remaining {
  padding: 0.45rem 1.3rem 0.55rem;
  border-top: 1px solid var(--line);
  text-align: right;
  font-size: 0.72rem;
  color: var(--faint);
  flex-shrink: 0;
}

.dots { display: flex; align-items: center; gap: 5px; height: 1.2rem; }
.dots span {
  width: 5px; height: 5px;
  background: var(--faint);
  border-radius: 50%;
  animation: bounce 1.1s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: 0.18s; }
.dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ── Listings (projects / research / elsewhere) ── */
.listing { margin-top: 3.25rem; }
.content .videos { margin-top: 0; }

.row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 1rem;
  align-items: baseline;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}
.row:last-child { border-bottom: 1px solid var(--line); }

a.row { transition: opacity 0.15s; }
a.row:hover { opacity: 1; }
a.row:hover .row-name { color: #000; }
a.row:hover .row-desc { color: var(--ink); }

.row-name {
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: color 0.15s;
}
.row-desc {
  color: var(--muted);
  font-size: 0.98rem;
  transition: color 0.15s;
}

/* ── Projects: plain cards, github mark + link ── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}
.project-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.1rem 1.15rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
}
.project-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.28);
  background: var(--field-focus);
}
.card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-gh {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.2s;
}
.card-gh svg { width: 17px; height: 17px; display: block; }
.project-card:hover .card-gh { color: var(--ink); }

.card-desc {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* tablet */
@media (max-width: 820px) {
  .page { max-width: 640px; }
  /* keep the nav rail aligned with the narrower content column */
  .nav-inner { max-width: 640px; gap: 1.25rem; }
  .nav-links { gap: 1.35rem; }
  .row { grid-template-columns: 230px 1fr; }
}

/* ── Elsewhere: brand logos in one row of equal tiles ── */
.elsewhere .section-label { text-align: center; }
.social-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}
.social-tile {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  transition: background 0.18s, border-color 0.18s, transform 0.15s;
}
.social-tile:hover {
  background: var(--field-focus);
  border-color: var(--ink);
  transform: translateY(-2px);
}
/* one box for every mark — the source aspect ratios differ, so cap both
   dimensions and let object-fit letterbox inside the same square */
.social-ico {
  max-width: 30px;
  max-height: 24px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  opacity: 0.9;
  transition: opacity 0.15s;
}
.social-tile:hover .social-ico { opacity: 1; }

/* dark-bg contrast: invert the black github mark; swap leetcode for its white version */
.ico-github { filter: invert(1); }
.ico-leetcode { content: url('/static/img/social/leetcode-white.webp'); }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .page { padding: 2.25rem 1.4rem 4.5rem; }
  /* One-line bar that swaps contents at the end of the hero (see the
     IntersectionObserver in index.html, which toggles body.past-hero).
     Both sets stay in place and cross-fade: the photo/CV hold their grid
     cells at opacity 0 and the links float centred on top, so the bar's
     height and column widths never move during the swap. */
  .nav-inner {
    position: relative;
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 48px;
    padding: 0.55rem 1.4rem;
    gap: 1.25rem;
  }

  .nav-brand,
  .nav-cv,
  .nav-links {
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* hero on screen — links only, centred over the bar */
  .nav-links {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    gap: 1.35rem;
    font-size: 0.9rem;
  }
  .nav-brand { grid-area: 1 / 1; justify-self: start; }
  .nav-cv    { grid-area: 1 / 2; justify-self: end; }
  .nav-brand,
  .nav-cv {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
  }

  /* past the hero — photo slides in left, CV right, links fade up and out */
  body.past-hero .nav-brand,
  body.past-hero .nav-cv {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  body.past-hero .nav-links {
    opacity: 0;
    transform: translate(-50%, calc(-50% - 6px));
    pointer-events: none;
  }

  .avatar { width: 48px; height: 48px; }
  .hero { margin-bottom: 3.5rem; }
  .hero-photo {
    width: 168px;
    height: 168px;
    margin-bottom: 2.25rem;
  }
  .marquee { --feather: 32px; }
  .marquee .video-embed { width: 208px; }
  .float-chip { font-size: 0.75rem; padding: 0.3rem 0.72rem; }
  .chip-educator  { left: -24%; }
  .chip-programmer { right: -30%; }
  .chip-engineer  { left: -20%; }
  .intro-title { font-size: 1.6rem; }
  .header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 1.1rem;
  }
  .row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}
