/* ============ tokens (matched to ethanxing.com) ============ */
:root {
  --bg: #f2f1ed;
  --bg-alt: #e7e4dd;
  --fg: #111111;
  --muted: #4a4a4a;
  --line: #1b1b1b;
  --uw-yellow: #d69a00;
  --uw-highlight: #ffd54f;
  --ascii: rgba(27, 27, 27, 0.62);

  --sans: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --mono: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --gutter: clamp(16px, 4vw, 52px);
}

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

html {
  scroll-behavior: smooth;
  min-height: 100%;
  margin: 0;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

img, video {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--uw-highlight);
  color: var(--fg);
}

::-moz-selection {
  background: var(--uw-highlight);
  color: var(--fg);
}

/* ============ top navigator (pure html + css) ============ */
.site-top-nav {
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  transition: opacity 0.18s ease;
}

.site-top-nav a {
  color: var(--fg);
  text-decoration: none;
  text-transform: lowercase;
  transition: color 0.15s ease;
}

.site-top-nav a:hover {
  color: var(--muted);
}

body.modal-open .site-top-nav {
  opacity: 0;
  pointer-events: none;
}

/* ============ page & dot grid background ============ */
.page {
  position: relative;
  overflow-x: clip;
  background: var(--bg);
  color: var(--fg);
}

.dot-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.3;
  background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.2) 1px, transparent 0);
  background-size: 22px 22px;
  z-index: 0;
}

/* ============ full-screen sections (no leaking) ============ */
.section {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 24px 68px;
  scroll-margin-top: 0;
}

.container {
  width: 100%;
  max-width: 768px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.container-wide {
  max-width: 1040px;
}

.section-heading {
  margin: 0 0 40px;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  text-transform: lowercase;
  color: var(--fg);
}

/* ============ me section ============ */
.section-me {
  padding-top: 64px;
  padding-bottom: 64px;
}

.hero-name {
  margin: 0;
  font-size: clamp(38px, 6vw, 60px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-transform: lowercase;
  color: var(--fg);
  cursor: default;
}

.g-char {
  display: inline-block;
  text-align: center;
}

.hero-bio {
  margin: 22px 0 0;
  max-width: 590px;
  font-size: clamp(16px, 1.5vw, 18px);
  line-height: 1.625;
  color: var(--muted);
  text-transform: lowercase;
}

.hero-bio strong {
  font-weight: 700;
  color: var(--fg);
}

.hero-bio .uw {
  font-weight: 700;
  color: var(--uw-yellow);
}

.hero-bio-swap {
  min-height: 3.25em;
  transition: opacity 0.16s ease;
}

.hero-bio-swap.swapping {
  opacity: 0.35;
}

.dino-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  margin-left: 7px;
  vertical-align: -4px;
  cursor: pointer;
}

.dino-btn:focus-visible {
  outline: 2px solid var(--uw-yellow);
  outline-offset: 3px;
  border-radius: 3px;
}

.dancing-dino {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
  user-select: none;
  transform-origin: 50% 85%;
  animation: dino-dance 1.05s ease-in-out infinite;
}

@keyframes dino-dance {
  0%   { transform: rotate(-30deg) translateY(0px); }
  25%  { transform: rotate(0deg) translateY(-4px); }
  50%  { transform: rotate(30deg) translateY(0px); }
  75%  { transform: rotate(0deg) translateY(-4px); }
  100% { transform: rotate(-30deg) translateY(0px); }
}

.latest-build {
  margin: 22px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  text-transform: lowercase;
}

.latest-build a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid rgba(27, 27, 27, 0.32);
  padding-bottom: 1px;
  margin-left: 6px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.latest-build a:hover {
  color: var(--muted);
  border-color: var(--uw-yellow);
}

.reach-label {
  margin: 34px 0 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: lowercase;
}

.me-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.social-row {
  margin-left: -9px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-link {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  color: var(--fg);
  transition: opacity 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

.icon-link svg {
  width: 24px;
  height: 24px;
}

.icon-link:hover {
  opacity: 0.72;
  transform: translateY(-1px);
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.85));
}

.icon-email {
  color: #d93025;
}

.icon-github {
  color: #181717;
}

.icon-linkedin {
  color: #0a66c2;
}

.icon-instagram {
  color: #e4405f;
}

.resume-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 4px;
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  text-transform: lowercase;
  transition: opacity 0.2s ease, color 0.15s ease, transform 0.2s ease;
}

.resume-link svg {
  width: 20px;
  height: 20px;
}

.resume-link:hover {
  color: var(--muted);
  opacity: 0.8;
  transform: translateY(-1px);
}

/* ============ experience section ============ */
.section-experience .section-heading {
  margin-bottom: 44px;
}

.timeline-wrap {
  position: relative;
  margin-left: -34px;
  padding-left: 34px;
  width: min(1060px, calc(100vw - max(24px, (100vw - 768px) / 2) + 10px));
  padding-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
  --fade-l: 0%;
  --fade-r: 90%;
  mask-image: linear-gradient(to right, transparent 0%, #000 var(--fade-l), #000 var(--fade-r), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 var(--fade-l), #000 var(--fade-r), transparent 100%);
}

.timeline-wrap::-webkit-scrollbar {
  display: none;
}

.timeline-track {
  position: relative;
  display: inline-block;
  min-width: 100%;
  padding-bottom: 12px;
}

.timeline-line {
  pointer-events: none;
  position: absolute;
  left: 0;
  right: -120px;
  top: 24px;
  height: 1px;
  background: rgba(27, 27, 27, 0.35);
}

.timeline-list {
  position: relative;
  display: flex;
  gap: 52px;
  list-style: none;
  margin: 0;
  padding: 0 96px 0 0;
}

.timeline-item {
  position: relative;
  flex: 0 0 264px;
  padding-top: 48px;
}

.timeline-dot {
  position: absolute;
  left: 0;
  top: 18px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--line);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.timeline-item:hover .timeline-dot {
  background: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.95);
}

.timeline-badge {
  position: absolute;
  left: -28px;
  top: 78px;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid rgba(27, 27, 27, 0.14);
  background: #ffffff;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 1px;
}

.timeline-badge-sdm {
  background: #e3242b;
  padding: 0;
}

.timeline-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.timeline-date {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: lowercase;
}

.timeline-role {
  margin: 14px 0 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--fg);
  text-transform: lowercase;
}

.timeline-org {
  margin: 8px 0 0;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: lowercase;
}

.timeline-desc {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.625;
  color: var(--muted);
  text-transform: lowercase;
}

.timeline-lor {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  text-transform: lowercase;
  transition: color 0.15s ease;
}

.timeline-lor:hover {
  color: var(--muted);
}

/* ============ projects section (dual scrollable collections) ============ */
.section-projects {
  padding-top: 66px;
  padding-bottom: 40px;
}

.projects-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 12px;
}

.projects-title-group {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-left: max(0px, calc((100% - 768px) / 2));
}

.projects-header-row .section-heading {
  margin-bottom: 0;
}

.projects-hint {
  font-size: clamp(11px, 1.66vw, 16px);
  font-weight: 400;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0;
}

.projects-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.projects-col {
  min-width: 0;
}

.projects-col-label {
  margin: 0 0 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: lowercase;
}

.projects-viewport {
  position: relative;
  margin: 0 -8px;
  padding: 0 8px;
}

.projects-fade {
  pointer-events: none;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 20;
  transition: opacity 0.18s ease;
}

.projects-fade-top {
  top: 0;
  height: 42px;
  opacity: 0;
  background: linear-gradient(
    to bottom,
    rgba(242, 241, 237, 0.82) 0%,
    rgba(242, 241, 237, 0.42) 55%,
    rgba(242, 241, 237, 0) 100%
  );
  backdrop-filter: blur(1.2px);
  -webkit-backdrop-filter: blur(1.2px);
  mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
}

.projects-fade-top.active {
  opacity: 1;
}

.projects-fade-bottom {
  bottom: 0;
  height: 44px;
  opacity: 1;
  background: linear-gradient(
    to top,
    rgba(242, 241, 237, 0.78) 0%,
    rgba(242, 241, 237, 0.38) 55%,
    rgba(242, 241, 237, 0) 100%
  );
}

.projects-fade-bottom.hidden {
  opacity: 0;
}

.projects-list {
  list-style: none;
  margin: 0;
  padding: 4px 4px 56px;
  height: min(33.5rem, calc(100vh - 240px));
  min-height: 360px;
  overflow-y: auto;
  perspective: 1000px;
  scrollbar-width: none;
  overscroll-behavior: auto;
}

.projects-list::-webkit-scrollbar {
  display: none;
}

.project-card {
  margin-bottom: 12px;
  border: 1px solid rgba(27, 27, 27, 0.2);
  background: rgba(242, 241, 237, 0.78);
  padding: 13px;
  transform-origin: center center;
  will-change: transform, opacity, filter;
  transition: border-color 0.15s ease;
}

.project-card:hover {
  border-color: rgba(27, 27, 27, 0.38);
}

.project-card-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.project-thumb {
  width: 82px;
  height: 82px;
  flex: 0 0 82px;
  margin-top: 2px;
  overflow: hidden;
  background: var(--bg-alt);
  border: 1px solid rgba(27, 27, 27, 0.1);
  display: grid;
  place-items: center;
}

.project-thumb img,
.project-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.project-thumb-placeholder {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
}

.project-meta {
  min-width: 0;
  flex: 1;
}

.project-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--fg);
  text-transform: lowercase;
}

.project-stack {
  margin: 3px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-transform: lowercase;
}

.project-summary {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
  text-transform: lowercase;
}

.project-view-btn {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  cursor: pointer;
  text-transform: lowercase;
  transition: color 0.15s ease;
}

.project-view-btn:hover {
  color: var(--muted);
}

/* ============ blog section ============ */
.section-blog .section-heading {
  margin-bottom: 20px;
}

.blog-soon {
  margin: 0;
  font-size: clamp(16px, 1.5vw, 18px);
  line-height: 1.625;
  color: var(--muted);
  text-transform: lowercase;
}

/* ============ footer (matched to ethanxing.com) ============ */
.site-footer {
  position: relative;
  z-index: 1;
  padding: 16px 24px 48px;
}

.footer-inner {
  border-top: 1px solid rgba(27, 27, 27, 0.25);
  padding-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.footer-credit {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  text-transform: lowercase;
}

.footer-sub {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: lowercase;
}

.footer-socials {
  margin-top: 14px;
  margin-left: -9px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-emblem {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  user-select: none;
}

.footer-emblem svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============ corner ascii art (kept per section) ============ */
.corner {
  position: absolute;
  right: var(--gutter);
  bottom: 24px;
  margin: 0;
  z-index: 1;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.corner pre {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(4.8px, min(0.56vw, 0.92vh), 8px);
  line-height: 1;
  color: var(--ascii);
  white-space: pre;
}

.corner.corner-me {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  right: var(--gutter);
}

.corner.corner-torus {
  top: clamp(72px, 12vh, 128px);
  bottom: auto;
  right: var(--gutter);
}

.corner.corner-inline {
  position: static;
  right: auto;
  bottom: auto;
  margin: 0;
  flex-shrink: 0;
}

.corner.corner-projects pre {
  font-size: clamp(3.6px, 0.42vw, 5.2px);
  line-height: 0.95;
}

.corner.corner-torus pre {
  font-size: clamp(3.6px, 0.42vw, 5.2px);
  line-height: 0.95;
}

/* ============ project detail modal ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  position: relative;
  width: min(92vw, 980px);
  aspect-ratio: 16 / 10;
  max-height: 84vh;
  display: grid;
  grid-template-columns: 2fr 3fr;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid rgba(27, 27, 27, 0.25);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  transform: translateY(8px) scale(0.985);
  transition: transform 0.2s ease;
}

.modal-backdrop.open .modal-box {
  transform: translateY(0) scale(1);
}

.modal-media-pane {
  position: relative;
  min-height: 240px;
  height: 100%;
  background: #171717;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-media-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-media-stage.light-bg {
  background: var(--bg-alt);
}

.modal-media-stage img,
.modal-media-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.modal-media-empty {
  font-family: var(--mono);
  font-size: 12px;
  color: rgba(242, 241, 237, 0.65);
  text-transform: lowercase;
}

.modal-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(242, 241, 237, 0.35);
  background: rgba(17, 17, 17, 0.62);
  color: #f2f1ed;
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.modal-arrow:hover {
  background: rgba(17, 17, 17, 0.88);
  border-color: rgba(242, 241, 237, 0.7);
}

.modal-arrow-prev {
  left: 10px;
}

.modal-arrow-next {
  right: 10px;
}

.modal-arrow[hidden] {
  display: none;
}

.modal-media-meta {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 18px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.68), transparent);
  color: rgba(242, 241, 237, 0.92);
  font-size: 11px;
  pointer-events: none;
  text-transform: lowercase;
}

.modal-media-meta[hidden] {
  display: none;
}

.modal-media-counter {
  font-family: var(--mono);
  flex-shrink: 0;
}

.modal-info-pane {
  position: relative;
  height: 100%;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--bg);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.modal-close:hover {
  color: var(--fg);
}

.modal-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--fg);
  text-transform: lowercase;
}

.modal-stack {
  margin: 8px 0 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: lowercase;
}

.modal-body {
  margin-top: 20px;
  font-size: 15px;
  line-height: 1.625;
  color: var(--muted);
  text-transform: lowercase;
}

.modal-intro {
  margin: 0 0 18px;
}

.modal-bullets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-bullet {
  display: grid;
  grid-template-columns: 1ch 1fr;
  column-gap: 8px;
  min-width: 0;
}

.modal-bullet.sub {
  margin-left: 3ch;
}

.modal-links {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.modal-links:empty {
  display: none;
}

.modal-links a {
  font-size: 13px;
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  text-transform: lowercase;
  transition: color 0.15s ease;
}

.modal-links a:hover {
  color: var(--muted);
}

/* ============ responsive ============ */
@media (max-width: 1180px) {
  .corner:not(.corner-inline) {
    opacity: 0.5;
  }
}

@media (max-width: 900px) {
  .projects-columns {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .projects-list {
    height: 360px;
  }
}

@media (max-width: 820px) {
  .corner:not(.corner-inline) {
    display: none;
  }

  .modal-box {
    aspect-ratio: auto;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 42vh) 1fr;
    max-height: 90vh;
  }

  .modal-info-pane {
    justify-content: flex-start;
    padding: 22px;
  }

  .timeline-wrap {
    margin-left: 0;
    padding-left: 28px;
    width: 100%;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 540px) {
  .site-top-nav {
    gap: 16px;
    font-size: 13px;
  }

  .corner-projects {
    display: none;
  }

  .project-card-inner {
    flex-direction: column;
    gap: 10px;
  }

  .project-thumb {
    width: 72px;
    height: 72px;
    flex-basis: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
