/* ============================================
   Huamin (Lucas) Lu — Engineering Portfolio
   Theme: black / white, circuit-trace accents,
   monospace engineering aesthetic
   ============================================ */

:root {
  --bg: #0a0a0a;
  --bg-raised: #111111;
  --bg-card: #141414;
  --fg: #f2f2f2;
  --fg-dim: #9a9a9a;
  --fg-faint: #555555;
  --line: #2a2a2a;
  --line-bright: #3d3d3d;
  --accent: #ffffff;
  --mono: "Share Tech Mono", "JetBrains Mono", Consolas, monospace;
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

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

p, li, a, h1, h2, h3, h4, span, figcaption, .caption {
  overflow-wrap: break-word;
  word-break: break-word;
}

b, strong { font-weight: 900; }
h1, h2, h3 { font-weight: 800; }

a { color: var(--fg); text-decoration: none; }

::selection { background: #333333; color: #ffffff; }
::-moz-selection { background: #333333; color: #ffffff; }

/* ---------- circuit trace edges ---------- */

.circuit-edge {
  width: 100%;
  height: 28px;
  display: block;
  opacity: 0.5;
  flex-shrink: 0;
  background-repeat: repeat-x;
  background-size: 280px 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='56' viewBox='0 0 420 56'%3E%3Cg stroke='%23ffffff' stroke-width='1.2' fill='none' opacity='0.55'%3E%3Cpath d='M0 10 H60 L75 25 H140'/%3E%3Cpath d='M0 30 H35 L50 45 H120 L135 30 H200'/%3E%3Cpath d='M160 10 H240 L255 25 H330'/%3E%3Cpath d='M220 45 H290 L305 30 H370'/%3E%3Cpath d='M350 10 H420'/%3E%3Cpath d='M390 30 H420'/%3E%3Cpath d='M75 25 V40'/%3E%3Cpath d='M255 25 V8'/%3E%3C/g%3E%3Cg fill='%23ffffff' opacity='0.55'%3E%3Ccircle cx='140' cy='25' r='3'/%3E%3Ccircle cx='200' cy='30' r='3'/%3E%3Ccircle cx='330' cy='25' r='3'/%3E%3Ccircle cx='370' cy='30' r='3'/%3E%3Ccircle cx='75' cy='40' r='2.5'/%3E%3Ccircle cx='255' cy='8' r='2.5'/%3E%3Ccircle cx='140' cy='25' r='6' fill='none' stroke='%23ffffff' stroke-width='1'/%3E%3Ccircle cx='330' cy='25' r='6' fill='none' stroke='%23ffffff' stroke-width='1'/%3E%3C/g%3E%3C/svg%3E");
}

.circuit-edge.bottom { transform: scaleY(-1); }

/* ---------- header / nav ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--fg);
}

.logo .prompt { color: var(--fg-faint); }

.logo .cursor {
  display: inline-block;
  width: 8px;
  height: 12px;
  background: var(--fg);
  margin-left: 4px;
  vertical-align: -2px;
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

nav ul {
  list-style: none;
  display: flex;
  gap: 16px;
  align-items: center;
}

nav a {
  display: block;
  padding: 6px 12px;
  font-size: 16px;
  color: var(--fg-dim);
  letter-spacing: 0.05em;
  transition: color 0.15s, border-color 0.15s;
}

/* top-level nav items are compact outlined buttons, vertically centered in the bar */
nav ul > li > a {
  border: 1px solid var(--line-bright);
  padding: 0 14px;
  height: 27px;
  display: flex;
  align-items: center;
  font-size: 14px;
  letter-spacing: 0.09em;
  line-height: 1;
}

.dropdown > a::after { line-height: 1; }

nav a:hover, nav a.active { color: var(--fg); }

nav ul > li > a:hover, nav ul > li > a.active { border-color: var(--fg-dim); }

/* dropdown */
.dropdown { position: relative; }

.dropdown > a::after {
  content: "\00a0\00a0▾";
  font-size: 13px;
  color: var(--fg-faint);
  transition: transform 0.2s ease;
}

.dropdown.open > a::after {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 270px;
  max-height: min(76vh, 490px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(18, 18, 20, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line-bright);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 1px rgba(255, 255, 255, 0.2);
  padding: 6px 0;
  display: none;
  z-index: 105;
}

.dropdown-menu::-webkit-scrollbar {
  width: 5px;
}
.dropdown-menu::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}
.dropdown-menu::-webkit-scrollbar-thumb {
  background: var(--line-bright);
  border-radius: 3px;
}
.dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: var(--fg-dim);
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu,
.dropdown.open .dropdown-menu { display: block; }

.dropdown-menu a {
  padding: 9px 16px;
  color: var(--fg-dim);
  font-size: 15px;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

.dropdown-menu a:hover { background: #262626; color: #ffffff; }
.dropdown-menu a:hover .idx { color: #9a9a9a; }
.dropdown-menu a:active { background: #333333; color: #ffffff; }

.dropdown-menu a .idx { color: var(--fg-faint); margin-right: 8px; }

/* ---------- layout ---------- */

main { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.section-label {
  font-size: 12.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 6px;
}

.section-label::before { content: "// "; }

/* ---------- above-the-fold: hero + tiles + button fit one screen ---------- */

/* ---------- above-the-fold: hero + tiles + button fit one screen ---------- */

.fold {
  /* viewport minus sticky header (44px) and top circuit edge (28px) */
  height: calc(100svh - 78px);
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

/* ---------- home hero ---------- */

.hero {
  padding: clamp(4px, 1vh, 12px) 0 clamp(2px, 0.6vh, 6px);
  text-align: center;
}

.hero h1 {
  font-size: clamp(20px, min(3.5vw, 4vh), 32px);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.hero .subtitle {
  margin-top: 3px;
  color: var(--fg-dim);
  font-size: clamp(12px, min(1.3vw, 1.8vh), 14.5px);
  letter-spacing: 0.05em;
}

.hero .subtitle span { color: var(--fg-faint); }

/* ---------- home: vertical tiles marquee ---------- */

body { overflow-x: hidden; } /* full-bleed row must never cause sideways page scroll */

.tiles {
  position: relative;
  overflow: hidden;
  width: 86vw;
  margin-left: calc(50% - 43vw);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.tiles-track {
  display: flex;
  align-items: stretch;
  gap: 16px;
  height: 100%;
  width: max-content;
  will-change: transform;
  padding: 8px 0 10px;
}
.tiles.dragging { cursor: grabbing; }
.tiles.dragging .tile { pointer-events: none; }
.tiles img { -webkit-user-drag: none; }

/* Marquee media virtualization (js/dragscroll.js): a tile parked more than one
   tile-width off screen keeps its layout box but its image area is not painted,
   so its video / animated images stop decoding. It is un-parked before it can
   scroll into view, so this is never visible to the visitor. */
.tiles .tile.is-offscreen .tile-img { visibility: hidden; }

/* inside the fold, tiles absorb the majority of height for portrait display */
.fold .tiles {
  flex: 1;
  min-height: 0;
  padding-top: clamp(4px, 0.8vh, 8px);
  padding-bottom: clamp(4px, 1vh, 10px);
}

.fold .tiles .tile-img {
  flex: 1 1 auto;
  min-height: 180px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  position: relative;
}

.fold .tiles .tile-img img,
.fold .tiles .tile-img video,
.grid-tile .tile-img img,
.grid-tile .tile-img video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fold .tiles .tile-img.ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  gap: 6px;
}

.fold .tiles .tile-img.ph .ph-icon { font-size: 24px; }
.fold .tiles .tile-img.ph .ph-label { font-size: 11.5px; }
.fold .tiles .tile-img.ph .ph-desc { font-size: 10px; line-height: 1.3; max-width: 200px; text-align: center; }

/* wide, compact "See All Projects" button under the marquee */
.see-all-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 8px;
  margin: 2px 4px clamp(6px, 1.2vh, 10px);
  padding: 5px 20px;
  height: 30px;
  border: 1px solid var(--line-bright);
  background: var(--bg-card);
  color: var(--fg);
  font-size: 13.5px;
  letter-spacing: 0.08em;
  transition: border-color 0.2s, background 0.2s;
}

.see-all-btn .arrow { transition: transform 0.2s; }
.see-all-btn:hover { border-color: var(--fg); background: var(--bg-raised); }
.see-all-btn:hover .arrow { transform: translateX(6px); }

.tiles .tile {
  flex: 0 0 clamp(230px, 23vw, 290px);
  scroll-snap-align: start;
}

.tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--bg-card);
  transition: border-color 0.22s ease, background 0.22s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease;
}

.tile:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: #191919;
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65), 0 0 1px rgba(255, 255, 255, 0.18);
}

.tile:active {
  border-color: rgba(255, 255, 255, 0.5);
  background: #222222;
  transform: translateY(-1px);
}

.tile-img {
  aspect-ratio: 3 / 4;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

.tile-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Split card image: finished physical photo (top) + CAD model (bottom) separated by crisp white line */
.tile-img.split-img {
  display: flex;
  flex-direction: column;
}

.tile-img.split-img .split-half {
  flex: 1 1 50%;
  height: 50%;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.tile-img.split-img .split-half img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.tile:hover .tile-img.split-img .split-half img,
.grid-tile:hover .tile-img.split-img .split-half img {
  transform: scale(1.03);
}

.tile-img.split-img .split-divider {
  display: none;
}

/* Cycling crossfade gallery for preview tiles and split-halves */
.tile-img.fade-gallery,
.split-half.fade-gallery {
  position: relative;
  overflow: hidden;
}

.tile-img.fade-gallery img,
.split-half.fade-gallery img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease-in-out, transform 0.25s ease;
  pointer-events: none;
}

.tile-img.fade-gallery img.active,
.split-half.fade-gallery img.active {
  opacity: 1;
  pointer-events: auto;
}

.tile:hover .tile-img.fade-gallery img.active,
.grid-tile:hover .tile-img.fade-gallery img.active,
.tile:hover .split-half.fade-gallery img.active,
.grid-tile:hover .split-half.fade-gallery img.active {
  transform: scale(1.03);
}

/* 2x2 Grid preview for Unitree G1 overview tile */
.tile-img.g1-grid-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  background: #1e1e1e;
  overflow: hidden;
  position: relative;
}

.g1-cell.fade-gallery {
  position: relative;
  overflow: hidden;
  background: #080808;
  width: 100%;
  height: 100%;
}

.g1-cell.fade-gallery img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease-in-out, transform 0.25s ease;
  pointer-events: none;
}

.g1-cell.fade-gallery img.active {
  opacity: 1;
  pointer-events: auto;
}

.tile:hover .g1-cell.fade-gallery img.active,
.grid-tile:hover .g1-cell.fade-gallery img.active {
  transform: scale(1.04);
}

.tile-body {
  padding: 10px 12px 10px;
  flex-shrink: 0;
}

.tile-body h2 {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-body .tags {
  margin-top: 3px;
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-body p {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--fg-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-body .cta {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--fg);
  letter-spacing: 0.05em;
  transition: color 0.18s ease;
}

.tile:hover .tile-body .cta {
  color: #ffffff;
}

.tile-body .cta::after {
  content: " →";
  display: inline-block;
  transition: transform 0.2s ease;
}

.tile:hover .tile-body .cta::after {
  transform: translateX(4px);
}

/* ---------- about ---------- */

.about {
  border-top: 1px solid var(--line);
  padding: 48px 0 72px;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 40px;
}

.about-photo {
  aspect-ratio: 3 / 4;
  max-width: 340px;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  position: relative;
}

.about-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.about p { color: var(--fg-dim); font-size: 21px; }

.about p + p { margin-top: 14px; }

.about .highlight { color: var(--fg); }

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

.about-links a {
  font-size: 19px;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--line-bright);
  padding-bottom: 2px;
}

.about-links a:hover { color: var(--fg); border-color: var(--fg); }

/* ---------- about skills tags ---------- */

.about-skills {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.about-skills-group {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.about-skills-title {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f2f2f2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.about-skills-title::before {
  content: "▸";
  color: #ffffff;
  font-size: 11px;
}

.skills-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-pill {
  font-family: var(--mono);
  font-size: 13.5px;
  color: #b8b8b8;
  background: #141414;
  border: 1px solid #333333;
  padding: 5px 11px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  transition: all 0.18s ease;
  user-select: none;
}

.skill-pill:hover {
  color: #ffffff;
  background: #1c1c1c;
  border-color: #555555;
  transform: translateY(-1px);
}

/* ---------- projects grid page ---------- */

.grid-page { padding: 16px 0 48px; }

.grid-page h1 { font-size: clamp(22px, 3.2vw, 28px); font-weight: 800; margin-bottom: 4px; line-height: 1.2; }

.grid-page .lede { color: var(--fg-dim); font-size: 13.5px; margin-bottom: 18px; line-height: 1.4; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* On large screens, break the whole section (title + grid) out of the 1100px
   column to ~78% of the screen — the heading stays left-aligned with the tiles
   no matter how wide the grid expands. */
@media (min-width: 1200px) {
  .grid-page {
    width: 78vw;
    margin-left: calc(50% - 39vw);
  }
}

.grid-tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--bg-card);
  transition: border-color 0.22s ease, background 0.22s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease;
}

.grid-tile:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: #191919;
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65), 0 0 1px rgba(255, 255, 255, 0.18);
}

.grid-tile:active {
  border-color: rgba(255, 255, 255, 0.5);
  background: #222222;
  transform: translateY(-1px);
}

.grid-tile .tile-img { aspect-ratio: 3 / 4; }

.grid-tile .tile-body { padding: 10px 12px 12px; }
.grid-tile .tile-body h2 { font-size: 15px; font-weight: 700; line-height: 1.25; }
.grid-tile .tile-body .tags { font-size: 11px; margin-top: 3px; color: var(--fg-faint); }

/* ---------- project pages ---------- */

.project-header { padding: 14px 0 4px; }

.project-header .crumb { font-size: 13px; color: var(--fg-faint); margin-bottom: 4px; letter-spacing: 0.04em; }

.project-header .crumb a { color: var(--fg-dim); }

.project-header .crumb a:hover { color: var(--fg); }

.project-header h1 {
  font-size: clamp(20px, min(3.2vw, 3.6vh), 28px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.project-header .meta {
  margin-top: 8px;
  display: flex;
  gap: 8px 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--fg-dim);
  line-height: 1.3;
}

.project-header .meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 2px;
  letter-spacing: 0.03em;
}

.project-header .meta span b { color: var(--fg); font-weight: 700; }

.project-intro {
  margin-top: 8px;
  padding: 8px 14px;
  border-left: 2px solid var(--fg);
  background: var(--bg-raised);
  color: var(--fg-dim);
  font-size: 13px;
  line-height: 1.45;
}

/* key achievements — recruiter hook at top of each project */

.achievements {
  list-style: none;
  margin: 28px 0 0;
  display: grid;
  gap: 10px;
}

.achievements li {
  border: 1px solid var(--line);
  border-left: 2px solid var(--fg-dim);
  background: var(--bg-raised);
  padding: 12px 18px;
  font-size: 20px;
  color: var(--fg-dim);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.achievements li:hover {
  background: #1c1c1c;
  border-color: var(--line-bright);
  border-left-color: #ffffff;
}

.achievements li b { color: var(--fg); font-weight: 800; }

.achievements li::before { content: "▸ "; color: var(--fg); }

/* sub-project cards (G1 hub) */

.subproject-list { display: grid; gap: 16px; margin: 0 0 16px; }

.subproject {
  display: grid;
  grid-template-columns: 48px 140px 1fr auto;
  gap: 20px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--bg-card);
  padding: 14px 20px;
  transition: border-color 0.2s;
}

.subproject:hover { border-color: var(--fg-dim); }

.subproject .sp-num { font-size: 22px; color: var(--fg-faint); }

.subproject .sp-clip {
  width: 140px;
  height: 90px;
  overflow: hidden;
  background: #050505;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-bright);
}

.subproject .sp-clip video,
.subproject .sp-clip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.subproject h3 { font-size: 22px; font-weight: 800; }

.subproject .sp-desc { font-size: 19px; color: var(--fg-dim); margin-top: 4px; }

.subproject .sp-tags { font-size: 16px; color: var(--fg-faint); margin-top: 6px; letter-spacing: 0.04em; }

.subproject .sp-arrow { color: var(--fg-dim); font-size: 18px; }

@media (max-width: 860px) {
  .subproject { grid-template-columns: 1fr; gap: 12px; }
  .subproject .sp-num, .subproject .sp-arrow { display: none; }
  .subproject .sp-clip { width: 100%; height: 180px; }
}

/* section blocks */

.psection { padding: 48px 0 8px; }

.psection > h2 {
  font-size: 28px;
  font-weight: 800;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.psection > h2 .num { color: var(--fg-faint); margin-right: 12px; }

/* subsection galleries within project pages */
.sub-gallery {
  margin: 32px 0 40px;
}

.sub-gallery:first-of-type {
  margin-top: 18px;
}

.sub-heading {
  font-size: 19px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sub-heading .sub-num {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg-faint);
  letter-spacing: 0.08em;
}

.sub-gallery > .caption {
  font-size: 13.5px;
  color: var(--fg-dim);
  margin-bottom: 14px;
  line-height: 1.45;
}

/* image placeholders */

.ph {
  border: 1px dashed var(--line-bright);
  background:
    repeating-linear-gradient(45deg, transparent, transparent 12px,
      rgba(255,255,255,0.015) 12px, rgba(255,255,255,0.015) 24px),
    var(--bg-raised);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--fg-faint);
  text-align: center;
  padding: 20px;
}

.ph .ph-icon { font-size: 22px; opacity: 0.6; }

.ph .ph-label {
  font-size: 17px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.ph .ph-desc { font-size: 16px; max-width: 420px; }

/* figure layouts */

.fig-wide { margin: 0 0 36px; }

.fig-wide .ph { aspect-ratio: 21 / 9; width: 100%; }

.fig-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 0 0 36px;
}

.fig-row .ph { aspect-ratio: 4 / 3; }

/* big image beside text */
.fig-split {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 28px;
  align-items: start;
  margin: 0 0 36px;
}

.fig-split.reverse { grid-template-columns: 2fr 3fr; }

.fig-split .ph { aspect-ratio: 1 / 1; position: sticky; top: 84px; }

.fig-split.landscape .ph { aspect-ratio: 4 / 3; }

figcaption, .caption {
  margin-top: 10px;
  font-size: 19px;
  color: var(--fg-dim);
}

.caption b, figcaption b { color: var(--fg); font-weight: 800; }

.caption + .caption { margin-top: 12px; }

/* certificate banner & interactive demo iframe */

.certificate-banner {
  margin: 18px 0 24px;
  border: 1px solid var(--line-bright);
  background: var(--bg-card);
  padding: 10px;
  border-radius: 4px;
}

.certificate-banner .cert-img {
  width: 100%;
  max-height: 540px;
  object-fit: contain;
  display: block;
  border-radius: 2px;
  background: #ffffff;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

.certificate-banner .caption {
  margin-top: 10px;
  font-size: 15px;
  color: var(--fg-dim);
}

.demo-frame-container {
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line-bright);
  background: #0f1412;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  margin: 16px 0 10px;
}

.demo-frame {
  width: 100%;
  height: 680px;
  border: none;
  display: block;
}

/* =========================================================
   DUAL-FEED / PAIRED HARDWARE & PC TELEOPERATION STYLES
   ========================================================= */
.dual-feed {
  margin: 28px 0 36px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  overflow: hidden;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.dual-feed-media {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 3px;
  background: var(--line);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.feed-pane {
  flex: 1 1 50%;
  position: relative;
  background: #050505;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.feed-pane video,
.feed-pane img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 480px;
  object-fit: cover;
  display: block;
}

.feed-pane video {
  object-fit: contain;
}

.feed-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.feed-tag.pc-tag {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.dual-feed-caption {
  padding: 14px 18px;
  background: var(--bg-raised);
  border-top: 1px solid var(--line);
  font-size: 17px;
  color: var(--fg-dim);
  line-height: 1.5;
}

.dual-feed-caption .caption-title {
  color: var(--fg);
  font-weight: 700;
  margin-right: 6px;
}

@media (max-width: 768px) {
  .dual-feed-media {
    flex-direction: column;
  }
  .feed-pane {
    min-height: 200px;
    min-width: 0;
    width: 100%;
  }
  .feed-pane video {
    max-height: 360px;
    max-width: 100%;
    width: 100%;
  }
}


/* spec / calc blocks */

.spec-list {
  list-style: none;
  border: 1px solid var(--line);
  margin: 0 0 36px;
}

.spec-list li {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  padding: 10px 16px;
  font-size: 19px;
  border-bottom: 1px solid var(--line);
}

.spec-list li:last-child { border-bottom: none; }

.spec-list .k { color: var(--fg-faint); }

.spec-list .v { color: var(--fg); }

.calc {
  border: 1px solid var(--line);
  background: var(--bg-raised);
  padding: 22px 24px;
  margin: 0 0 36px;
  overflow-x: auto;
}

.calc .calc-title {
  font-size: 18px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 14px;
}

.calc .eq {
  font-size: 21px;
  color: var(--fg);
  padding: 4px 0;
  white-space: nowrap;
}

.calc .eq .result { color: var(--fg); font-weight: 700; }

.calc .note { margin-top: 12px; font-size: 19px; color: var(--fg-dim); white-space: normal; }

/* code blocks */

pre {
  border: 1px solid var(--line);
  background: #0d0d0d;
  padding: 20px 22px;
  overflow-x: auto;
  margin: 0 0 36px;
  font-size: 19px;
  line-height: 1.6;
}

pre .cm { color: #6a6a6a; }        /* comment */
pre .kw { color: #cccccc; font-weight: 800; } /* keyword */
pre .fn { color: #ffffff; }        /* function  */
pre .st { color: #b8b8b8; font-style: italic; } /* string */
pre .nm { color: #dddddd; }        /* number */

.code-label {
  font-size: 17px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 8px;
}

/* prev/next footer nav */

.project-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  margin-top: 48px;
  padding: 28px 0 64px;
}

.project-nav a { color: var(--fg-dim); font-size: 19px; }

.project-nav a:hover { color: var(--fg); }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--line);
  margin-top: 0;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 18px;
  color: var(--fg-faint);
}

.footer-inner a { color: var(--fg-dim); }

.footer-inner a:hover { color: var(--fg); }

/* ---------- scroll reveal ---------- */

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.visible { opacity: 1; transform: none; }

/* stagger for tile rows and achievement lists */
.tiles .reveal.visible:nth-child(2),
.achievements .reveal.visible:nth-child(2) { transition-delay: 0.08s; }
.tiles .reveal.visible:nth-child(3),
.achievements .reveal.visible:nth-child(3) { transition-delay: 0.16s; }
.tiles .reveal.visible:nth-child(4),
.achievements .reveal.visible:nth-child(4) { transition-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- media (photos & autoplay videos) ---------- */

.fig-wide img, .fig-split img, .fig-row img,
.fig-wide video, .fig-split video, .fig-row video {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

.fig-split > div, .fig-row > div {
  min-width: 0;
  overflow: hidden;
}

.tile-img img, .tile-img video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--line);
}

/* ---------- video viewport / scaled media frame (matching carousel height) ---------- */

.video-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9.5;
  max-height: 60vh;
  margin: 0 0 24px;
  border: 1px solid var(--line);
  background: #050505;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-box video {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border: none;
}

.fig-wide video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9.5;
  max-height: 60vh;
  object-fit: contain;
  background: #050505;
  border: 1px solid var(--line);
  margin: 0 0 24px;
}

/* ---------- interactive project carousel ---------- */

.carousel-box {
  position: relative;
  width: 100%;
  margin: 0 0 24px;
  border: 1px solid var(--line);
  background: #080808;
  overflow: hidden;
  user-select: none;
  cursor: grab;
}

.carousel-box.dragging {
  cursor: grabbing;
}

.carousel-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9.5;
  max-height: 60vh;
  overflow: hidden;
  background: #050505;
}

.carousel-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.35s cubic-bezier(0.25, 0.1, 0.25, 1.0);
  will-change: transform;
}

.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #060606;
}

.carousel-slide img,
.carousel-slide video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border: none;
}

.carousel-btn {
  position: absolute;
  top: calc(50% - 22px);
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.72);
  color: var(--fg);
  font-family: var(--font);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: all 0.15s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.carousel-btn:hover {
  background: rgba(25, 25, 25, 0.95);
  border-color: var(--fg);
  color: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.15);
}

.carousel-btn.prev { left: 14px; }
.carousel-btn.next { right: 14px; }

.carousel-caption-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 10, 10, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 4;
}

.carousel-counter {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.carousel-caption-text {
  font-size: 16px;
  color: var(--fg);
  line-height: 1.4;
  transition: opacity 0.18s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carousel-dots {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 4;
}

.carousel-btn:active {
  transform: translateY(-50%) scale(0.92);
}

.carousel-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  transition: width 0.25s cubic-bezier(0.3, 1.2, 0.4, 1), background 0.25s ease, box-shadow 0.25s ease;
}

.carousel-dots .dot.active {
  width: 18px;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.45);
  transform: none;
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .tiles, .project-grid { grid-template-columns: 1fr; }
  .about { grid-template-columns: 1fr; gap: 20px; }
  .fig-split, .fig-split.reverse { grid-template-columns: 1fr; }
  .fig-split .ph { position: static; }
  .fig-row { grid-template-columns: 1fr; }
  .spec-list li { grid-template-columns: 1fr; gap: 2px; }
  .nav-inner { padding: 0 16px; }
  nav ul > li > a { padding: 0 10px; font-size: 13px; }
}

/* ============================================================
   MOBILE (phones, portrait ≤ 640px) — full rescale.
   Desktop sizes are tuned for big monitors; phones get a
   compact type scale, tighter nav, and near-full-width tiles.
   ============================================================ */
@media (max-width: 640px) {

  body { font-size: 17px; }

  main { padding: 0 14px; }

  /* --- header: compact bar that fits logo + 3 buttons cleanly on all mobile screens down to 320px --- */
  .nav-inner { padding: 0 8px; height: 42px; width: 100%; max-width: 100%; }
  .logo { font-size: 13px; letter-spacing: 0.03em; flex-shrink: 0; }
  .logo .cursor { width: 6px; height: 10px; margin-left: 2px; }
  nav ul { gap: 4px; flex-shrink: 0; }
  nav ul > li > a { padding: 0 6px; height: 23px; font-size: 11px; letter-spacing: 0.03em; white-space: nowrap; }
  .dropdown > a::after { font-size: 9px; margin-left: 3px; }
  .dropdown-menu { min-width: 200px; }
  .dropdown-menu a { font-size: 12.5px; padding: 8px 10px; }

  .circuit-edge { height: 28px; background-size: 280px 28px; }

  /* --- home hero --- */
  .hero { padding: 8px 0 4px; }
  .hero h1 { font-size: clamp(20px, 6.2vw, 28px); }
  .hero .subtitle { font-size: 11.5px; padding: 0 4px; line-height: 1.35; letter-spacing: 0.03em; }

  /* --- marquee: full width, one tile ~fills the screen --- */
  .tiles {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    touch-action: pan-y;
  }
  .tiles-track {
    gap: 12px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .tiles .tile, .fold .tiles .tile { flex: 0 0 clamp(240px, 78vw, 300px); }
  .tile-body, .fold .tile-body { padding: 10px 12px 12px; }
  .tile-body h2, .fold .tile-body h2 { font-size: 15.5px; }
  .tile-body .tags, .fold .tile-body .tags { font-size: 11px; }
  .tile-body p, .fold .tile-body p { font-size: 12.5px; margin-top: 5px; }
  .tile-body .cta, .fold .tile-body .cta { font-size: 12px; margin-top: 6px; }

  .see-all-btn { font-size: 13px; padding: 6px 14px; margin: 6px auto 12px; width: calc(100% - 28px); max-width: 360px; }

  /* --- about --- */
  .section-label { font-size: 12px; }
  .about { padding: 24px 0 36px; gap: 20px; }
  .about p { font-size: 14px; }
  .about-links a { font-size: 13px; }
  .about-photo { width: 100%; max-width: none; margin: 8px auto 0; }

  /* --- projects grid page --- */
  .grid-page { padding: 10px 0 28px; }
  .grid-page h1 { font-size: 20px; margin-bottom: 3px; }
  .grid-page .lede { font-size: 12px; margin-bottom: 12px; }
  .project-grid { gap: 12px; }

  /* --- project pages --- */
  .project-header { padding: 8px 0 4px; }
  .project-header .crumb { font-size: 11px; margin-bottom: 2px; }
  .project-header h1 { font-size: clamp(17px, 5.5vw, 22px); line-height: 1.2; }
  .project-header .meta { gap: 6px 12px; font-size: 11px; margin-top: 4px; }
  .project-intro { font-size: 11.5px; padding: 6px 10px; margin-top: 6px; line-height: 1.35; }

  .achievements { gap: 8px; margin-top: 16px; }
  .achievements li { font-size: 13px; padding: 8px 10px; }
  .achievements a { word-break: break-all; overflow-wrap: anywhere; }

  .psection { padding: 24px 0 6px; }
  .psection > h2 { font-size: 18px; margin-bottom: 16px; }
  .psection > h2 .num { margin-right: 8px; }

  .caption, figcaption { font-size: 13px; }
  .fig-wide, .fig-row, .fig-split { margin-bottom: 20px; }
  .fig-split, .fig-split.reverse { gap: 12px; }
  .ph { padding: 12px; }
  .ph .ph-label { font-size: 10.5px; }
  .ph .ph-desc { font-size: 10.5px; }

  .spec-list li { font-size: 12px; padding: 7px 10px; }
  .calc { padding: 12px 12px; }
  .calc .calc-title { font-size: 10.5px; }
  .calc .eq { font-size: 12px; }
  .calc .note { font-size: 11.5px; }

  pre { font-size: 11px; padding: 10px 12px; margin-bottom: 20px; }
  .code-label { font-size: 10px; }

  .subproject { padding: 12px 14px; }
  .subproject h3 { font-size: 15px; }
  .subproject .sp-desc { font-size: 12px; }
  .subproject .sp-tags { font-size: 10.5px; }

  .project-nav { padding: 18px 0 36px; margin-top: 24px; }
  .project-nav a { font-size: 12px; }

  .footer-inner { font-size: 10.5px; padding: 14px; }

  /* carousel & video mobile */
  .carousel-box,
  .carousel-viewport { touch-action: pan-y; }
  .carousel-viewport,
  .video-box,
  .fig-wide video { aspect-ratio: 16 / 10; max-height: 52vh; }
  .carousel-btn { width: 34px; height: 34px; font-size: 16px; }
  .carousel-btn.prev { left: 8px; }
  .carousel-btn.next { right: 8px; }
  .carousel-caption-bar { padding: 8px 12px; gap: 8px; }
  .carousel-counter { font-size: 12px; }
  .carousel-caption-text { font-size: 13px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .carousel-dots { bottom: 58px; }
}

/* ---------- about entrance transitions ---------- */

.reveal-left { transform: translateX(-44px); }
.reveal-left.visible { transform: none; }

/* bio lines cascade in one after another */
.about div > p.reveal.visible:nth-of-type(2) { transition-delay: 0.12s; }
.about div > p.reveal.visible:nth-of-type(3) { transition-delay: 0.24s; }
.about div > p.reveal.visible:nth-of-type(4) { transition-delay: 0.36s; }
.about .about-links.reveal.visible { transition-delay: 0.5s; }

/* ---------- project-page fold: title + stats + intro + hero fill screen 1 ---------- */

.pfold {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pfold .project-header { padding-top: 4px; flex-shrink: 0; }

.pfold .fig-wide {
  flex: 1;
  min-height: 200px;
  margin: 8px 0 20px;
  display: flex;
}

.pfold .fig-wide .carousel-box,
.pfold .fig-wide .video-box,
.pfold .fig-wide .ph,
.pfold .fig-wide img,
.pfold .fig-wide video {
  width: 100%;
  height: 100%;
  flex: 1;
  margin: 0;
}

/* clip inside G1 sub-project cards: [num] [clip] [text] [arrow].
   The clip bleeds to the card's top/bottom edges — cut into the section. */
.subproject {
  grid-template-columns: 44px 190px 1fr auto;
  padding: 0 22px 0 18px;
  overflow: hidden;
}

.subproject > div:not(.sp-clip) { padding: 16px 0; }

.subproject .sp-clip {
  width: 190px;
  align-self: stretch;
  height: auto;
  border: none;
  padding: 8px;
  gap: 4px;
}

.subproject .sp-clip .ph-label { font-size: 10px; }
.subproject .sp-clip .ph-desc { font-size: 9.5px; }

.subproject .sp-clip img, .subproject .sp-clip video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

@media (max-width: 860px) {
  .subproject { grid-template-columns: 1fr; padding: 0 0 4px; }
  .subproject > div:not(.sp-clip) { padding: 4px 16px 12px; }
  .subproject .sp-clip { width: 100%; aspect-ratio: 16 / 9; align-self: auto; }
}

/* ---------- floating back to top button ---------- */
.back-to-top {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(14, 14, 16, 0.9);
  border: 1px solid var(--line-bright);
  color: var(--fg-dim);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 2px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  color: #fff;
  border-color: #888888;
  background: #1e1e1e;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.12);
}

/* ---------- copy feedback toast ---------- */
.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(26, 26, 28, 0.96);
  border: 1px solid var(--line-bright);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  padding: 6px 16px;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- keyboard accessibility focus-visible ---------- */
:focus-visible {
  outline: 1px solid #777777;
  outline-offset: 2px;
}
