/* Autonomous-driving 3D redesign: scene layers, HUD, tilt cards, autonomy stack. Loaded after styles.css. */
:root {
  --font-display: "Space Grotesk", Inter, ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --pink: #ff7ad9;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
}

h1 {
  letter-spacing: -0.055em;
}

h2 {
  letter-spacing: -0.04em;
}

.eyebrow,
.card-index,
.mini-label,
.badge,
.metric-label {
  font-family: var(--font-mono);
}

html,
body {
  overflow-x: hidden;
  overflow-x: clip;
}

#scene-3d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -2;
  transition: opacity 200ms linear;
}

html.has-3d #neural-canvas {
  display: none;
}

html:not(.has-3d) #scene-3d {
  display: none;
}

.scene-scrim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(5, 8, 22, 0.82) 0%, rgba(5, 8, 22, 0.5) 38%, rgba(5, 8, 22, 0.08) 68%, rgba(5, 8, 22, 0.35) 100%),
    linear-gradient(180deg, rgba(5, 8, 22, 0.2) 0%, transparent 30%, rgba(5, 8, 22, 0.55) 100%);
}

/* Hero */
.hero {
  min-height: min(920px, calc(100vh - 80px));
  min-height: min(920px, calc(100svh - 80px));
  grid-template-rows: 1fr auto auto;
  row-gap: 28px;
  padding-top: 72px;
  padding-bottom: 36px;
}

.hero-content {
  align-self: center;
}

.hero-card {
  align-self: start;
  justify-self: end;
  width: min(100%, 360px);
  margin-top: 24px;
}

@media (min-width: 1081px) {
  .hero-card .portrait-wrap {
    aspect-ratio: 1 / 1;
  }

  .hero-card .profile-mini {
    padding: 16px 6px 2px;
  }

  .hero-card .profile-mini h2 {
    font-size: 1.7rem;
  }
}

.hero h1 {
  text-shadow: 0 0 40px rgba(105, 230, 255, 0.22), 0 4px 30px rgba(5, 8, 22, 0.8);
}

.hero-summary {
  color: #c3cfe6;
  text-shadow: 0 2px 16px rgba(5, 8, 22, 0.9);
}

.hud {
  grid-column: 1 / -1;
  justify-self: start;
  display: none;
  flex-wrap: wrap;
  align-items: stretch;
  border: 1px solid rgba(101, 255, 200, 0.28);
  border-radius: 18px;
  background: rgba(5, 8, 22, 0.66);
  backdrop-filter: blur(14px);
  font-family: var(--font-mono);
  overflow: hidden;
}

html.has-3d .hud {
  display: flex;
}

.hud-cell {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 6px;
  align-items: baseline;
  justify-content: start;
  padding: 10px 18px;
  border-right: 1px solid rgba(101, 255, 200, 0.14);
  min-width: 108px;
}

.hud-cell span {
  grid-column: 1 / -1;
  color: var(--muted-2);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
}

.hud-cell b {
  color: var(--green);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.hud-cell i {
  color: var(--muted-2);
  font-size: 0.7rem;
  font-style: normal;
}

.hud-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--green);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
  animation: hudPulse 1.4s ease-in-out infinite;
}

@keyframes hudPulse {
  50% { opacity: 0.25; }
}

.scroll-cue {
  grid-column: 1 / -1;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.scroll-cue-track {
  position: relative;
  width: 22px;
  height: 34px;
  border: 1px solid rgba(105, 230, 255, 0.5);
  border-radius: 12px;
}

.scroll-cue-track span {
  position: absolute;
  left: 50%;
  top: 7px;
  width: 4px;
  height: 8px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--cyan);
  animation: cueDrop 1.8s ease-in-out infinite;
}

@keyframes cueDrop {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(12px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* Detection overlay on the portrait */
.detect-box {
  position: absolute;
  inset: 9% 12% 6%;
  pointer-events: none;
}

.detect-box .corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 0 solid var(--green);
  filter: drop-shadow(0 0 6px rgba(101, 255, 200, 0.8));
}

.corner.tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 6px; }
.corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 6px; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 6px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 6px; }

.detect-label {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 6px;
  color: #03101d;
  background: var(--green);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.scan-line {
  position: absolute;
  left: -14%;
  right: -14%;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(101, 255, 200, 0.9), transparent);
  box-shadow: 0 0 18px rgba(101, 255, 200, 0.7);
  animation: scan 4.2s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% { top: 0; opacity: 0; }
  10%, 90% { opacity: 1; }
  50% { top: 100%; }
}

/* 3D tilt cards */
.tilt {
  --rx: 0deg;
  --ry: 0deg;
  --lift: 0px;
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--lift));
  transition: transform 220ms ease-out, border-color 180ms ease, background 180ms ease, box-shadow 220ms ease;
}

.tilt:hover {
  --lift: -6px;
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--lift));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4), 0 0 46px rgba(105, 230, 255, 0.12);
}

.content-card.tilt:hover,
.metric-card.tilt:hover {
  border-color: rgba(105, 230, 255, 0.5);
  background:
    radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), rgba(105, 230, 255, 0.16), transparent 55%),
    var(--bg-card-strong);
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 30%), rgba(255, 255, 255, 0.14), transparent 45%);
  opacity: 0;
  transition: opacity 220ms ease;
}

.hero-card:hover::after {
  opacity: 1;
}

/* Scroll reveal (added by JS only, so content stays visible without it) */
.reveal {
  opacity: 0;
  transform: perspective(1000px) rotateX(16deg) translateY(40px);
  transform-origin: 50% 0;
  transition: opacity 700ms ease, transform 900ms cubic-bezier(0.2, 0.75, 0.2, 1);
}

.reveal.in {
  opacity: 1;
  transform: perspective(1000px) rotateX(0deg) translateY(0);
}

/* Autonomy stack */
.autonomy-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 48px;
}

.stack3d-stage {
  --size: 290px;
  --gap: 74px;
  display: grid;
  place-items: center;
  height: 500px;
  perspective: 1600px;
}

.stack3d {
  position: relative;
  width: var(--size);
  height: var(--size);
  margin: 0;
  padding: 0;
  list-style: none;
  transform-style: preserve-3d;
  transform: translateY(70px) rotateX(58deg) rotateZ(-40deg);
  animation: stackTurn 9s ease-in-out infinite alternate;
}

@keyframes stackTurn {
  from { transform: translateY(70px) rotateX(58deg) rotateZ(-46deg); }
  to { transform: translateY(70px) rotateX(56deg) rotateZ(-30deg); }
}

.stack3d-stage:hover {
  --gap: 104px;
}

.layer {
  --c: 105, 230, 255;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  padding: 22px 24px;
  border: 1px solid rgba(var(--c), 0.75);
  border-radius: 24px;
  background-color: rgba(8, 14, 36, 0.72);
  box-shadow: 0 0 36px rgba(var(--c), 0.22), inset 0 0 40px rgba(var(--c), 0.08);
  transform: translateZ(calc(var(--i) * var(--gap)));
  transition: transform 600ms cubic-bezier(0.2, 0.75, 0.2, 1);
}

.layer-perception {
  background-image: radial-gradient(rgba(var(--c), 0.55) 1.3px, transparent 1.8px);
  background-size: 16px 16px;
}

.layer-prediction {
  --c: 122, 140, 255;
  background-image: repeating-linear-gradient(135deg, rgba(var(--c), 0.24) 0 2px, transparent 2px 18px);
}

.layer-planning {
  --c: 101, 255, 200;
  background-image:
    radial-gradient(circle at 70% 30%, transparent 46%, rgba(var(--c), 0.5) 47%, rgba(var(--c), 0.5) 49%, transparent 50%),
    radial-gradient(circle at 70% 30%, transparent 62%, rgba(var(--c), 0.22) 63%, rgba(var(--c), 0.22) 64%, transparent 65%);
}

.layer-control {
  --c: 255, 122, 217;
  background-image:
    linear-gradient(rgba(var(--c), 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--c), 0.16) 1px, transparent 1px);
  background-size: 24px 24px;
}

.layer-tag {
  color: rgb(var(--c));
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
}

.layer strong {
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1.1;
}

.layer em {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-style: normal;
}

.autonomy-copy > p:not(.eyebrow) {
  color: var(--muted);
  margin: 18px 0 24px;
}

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

.autonomy-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-card);
}

.autonomy-list span {
  flex: none;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Robotics */
.robotics-section {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: center;
  gap: 48px;
}

.robotics-copy > p:not(.eyebrow) {
  color: var(--muted);
  margin: 18px 0 26px;
}

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

.robo-card {
  padding: 20px;
}

.robo-card h3 {
  margin: 8px 0 6px;
  font-size: 1.08rem;
}

.robo-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.robot-stage {
  position: relative;
  display: none;
  margin: 0;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(255, 122, 217, 0.28);
  border-radius: 32px;
  background:
    radial-gradient(circle at 50% 58%, rgba(189, 124, 255, 0.16), transparent 60%),
    rgba(5, 8, 22, 0.55);
  box-shadow: var(--shadow), 0 0 80px rgba(189, 124, 255, 0.1);
  overflow: hidden;
  cursor: crosshair;
  touch-action: pan-y;
}

.robot-stage.has-robot {
  display: block;
}

#robot-3d {
  display: block;
  width: 100%;
  height: 100%;
}

.robot-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted-2);
}

.robot-hud span {
  padding: 5px 10px;
  border: 1px solid rgba(255, 122, 217, 0.3);
  border-radius: 999px;
  background: rgba(5, 8, 22, 0.7);
}

.robot-hud b {
  color: var(--pink);
  font-variant-numeric: tabular-nums;
}

.robot-hint {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: center;
  pointer-events: none;
}

/* Five metric cards */
.metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1080px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card {
    padding: 20px;
    min-height: 112px;
  }
}

.project-card .stack-link,
.publication-body .stack-link {
  margin-top: 12px;
}

/* Book links */
.stack-link {
  display: inline-flex;
  margin-top: 14px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.stack-link:hover,
.stack-link:focus-visible {
  color: var(--green);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 1080px) {
  .hero {
    min-height: auto;
    grid-template-rows: auto;
    padding-top: 72px;
  }

  .hero-card {
    justify-self: start;
    width: min(100%, 420px);
  }

  .autonomy-section {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .autonomy-copy {
    order: -1;
  }

  .robotics-section {
    grid-template-columns: 1fr;
  }

  .robot-stage {
    width: min(100%, 560px);
    justify-self: center;
  }

  .scene-scrim {
    background: linear-gradient(180deg, rgba(5, 8, 22, 0.6) 0%, rgba(5, 8, 22, 0.52) 50%, rgba(5, 8, 22, 0.72) 100%);
  }
}

@media (max-width: 820px) {
  .hud {
    justify-self: stretch;
  }

  .hud-cell {
    min-width: 0;
    flex: 1 1 30%;
    padding: 9px 14px;
  }

  .hud-status {
    flex: 1 1 100%;
    border-top: 1px solid rgba(101, 255, 200, 0.14);
  }

  .stack3d-stage {
    --size: 230px;
    --gap: 58px;
    height: 420px;
  }

  .stack3d-stage:hover {
    --gap: 72px;
  }

  .layer {
    padding: 16px 18px;
  }

  .layer strong {
    font-size: 1.25rem;
  }

  .scroll-cue-text {
    display: none;
  }
}

@media (max-width: 620px) {
  .hero {
    padding-top: 48px;
    row-gap: 22px;
  }

  .hero-glow {
    left: -40%;
    width: 140%;
  }

  .hero-actions .btn {
    flex: 1 1 calc(50% - 6px);
  }

  .hud-cell:nth-child(3),
  .hud-cell:nth-child(5) {
    display: none;
  }

  .hud-cell b {
    font-size: 0.95rem;
  }

  .stack3d-stage {
    --size: 190px;
    --gap: 50px;
    height: 360px;
  }

  .layer em {
    display: none;
  }

  .robotics-grid {
    grid-template-columns: 1fr;
  }

  .detect-label {
    font-size: 0.62rem;
  }
}

@media (max-width: 380px) {
  .stack3d-stage {
    --size: 165px;
    --gap: 44px;
    height: 320px;
  }

  .layer strong {
    font-size: 1.05rem;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .scroll-cue {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stack3d {
    animation: none;
  }

  .scan-line,
  .scroll-cue-track span {
    display: none;
  }
}
