/* ---------- Portfolio (/portfolio) ----------
   Loaded only on /portfolio. 3D pieces drawn by lab/*.js; without JavaScript the content still reads as plain sections. */
.terrain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.terrain canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.lab main,
.lab .site-footer {
  position: relative;
  z-index: 1;
}

/* Hero: tall, so scrolling it tilts the map (JS sets --p from 0 to 1) */
.hero {
  position: relative;
  height: 220vh;
}

.hero-stage {
  position: sticky;
  top: 0;
  display: grid;
  place-items: center;
  height: 100vh;
  height: 100svh;
  padding: 0 24px;
  text-align: center;
}

.hero-text {
  opacity: calc(1 - var(--p, 0) * 2.4);
  transform: translateY(calc(var(--p, 0) * -48px));
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 7.5vw, 4.25rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.hero-role {
  margin: 8px 0 0;
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: var(--muted);
}

.hero-summary {
  max-width: 420px;
  margin: 18px auto 0;
  font-size: 0.95rem;
  color: var(--text-soft);
}

/* Work | About | Contact, split by short vertical lines */
.hero-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 32px;
}

.hero-links .link-divider {
  width: 1px;
  height: 14px;
}

.hero-caption {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 16%;
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-soft);
  opacity: clamp(0, (var(--p, 0) - 0.62) * 3.2, 1);
  transform: translateY(calc((1 - var(--p, 0)) * 16px));
}

.scroll-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  margin: 0;
  opacity: calc(1 - var(--p, 0) * 4);
}

/* "Scroll" over a short line with a light that runs down it */
.scroll-hint .intro {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-soft);
  animation: fade-up 0.9s var(--ease-out) both, breathe 3.2s var(--ease) 2s infinite;
  animation-delay: calc(0.15s + var(--delay, 0s)), 2s;
}

.scroll-hint .intro::after {
  content: "";
  width: 1px;
  height: 28px;
  background: linear-gradient(var(--text-soft), var(--text-soft)) 0 0 / 1px 10px no-repeat, var(--line-strong);
  animation: scroll-line 2s var(--ease) infinite;
}

@keyframes scroll-line {
  from {
    background-position: 0 -10px, 0 0;
  }
  to {
    background-position: 0 28px, 0 0;
  }
}

/* Each experiment: centered heading, then the stage */
.exp {
  padding: 120px 0 40px;
  text-align: center;
}

.exp-head {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 24px;
}

.exp-index {
  display: block;
  margin-bottom: 10px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--subtle);
}

.exp h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.exp-head p {
  margin: 10px 0 0;
  color: var(--muted);
}

/* The main text of a section (about, contact) */
.exp-head .exp-lead {
  max-width: 480px;
  margin: 18px auto 0;
  color: var(--text-soft);
}

.exp-head .exp-note {
  margin-top: 16px;
  font-size: 0.875rem;
}

.exp-head .contact-email {
  margin: 18px 0 0;
}

.stage {
  position: relative;
  width: calc(100% - 48px);
  max-width: var(--max-width);
  margin: 32px auto 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y; /* sideways drags turn things, vertical swipes still scroll */
}

.js .stage {
  height: clamp(380px, 62vh, 560px);
}

.stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.cloud canvas,
.globe {
  cursor: grab;
}

.cloud canvas:active,
.globe:active {
  cursor: grabbing;
}

/* Buttons under a stage */
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 560px;
  margin: 20px auto 0;
  padding: 0 24px;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.chip:hover {
  color: var(--text);
  border-color: var(--subtle);
}

.chip[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* 01: project cards. The first is featured: full width, cover beside the text */
.projects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  width: calc(100% - 48px);
  max-width: var(--max-width);
  margin: 40px auto 0;
  text-align: left;
  perspective: 1400px;
}

.project {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(17, 17, 19, 0.92);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.7s var(--ease-out), border-color 0.3s var(--ease);
}

/* Follows the pointer closely while tilting, eases back when it leaves */
.project.is-tilting {
  transition: transform 0.15s linear, border-color 0.3s var(--ease);
}

.project:hover,
.project:focus-within {
  border-color: var(--subtle);
}

/* .reveal sets its own transform; once revealed, the tilt takes over */
.js .project.reveal.is-visible {
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
}

.project-cover {
  position: relative;
  height: 168px;
  border-bottom: 1px solid var(--line);
  background: #0e0e10;
  overflow: hidden;
}

.project-cover canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.project-index,
.project-year {
  position: absolute;
  top: 14px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.project-index {
  left: 16px;
}

.project-year {
  right: 16px;
}

.project-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 24px 24px 26px;
}

.project h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.project-summary {
  margin: 8px 0 18px;
  font-size: 0.95rem;
  color: var(--text-soft);
}

.project-highlights {
  display: grid;
  gap: 6px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  color: var(--muted);
}

/* small square bullets, like the peak marker on the covers */
.project-highlights li::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin: 0 10px 2px 0;
  background: var(--subtle);
  vertical-align: middle;
}

.project-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-stack li {
  padding: 2px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--muted);
}

/* Links (or the status) sit at the bottom, so cards in a row line up */
.project-footer {
  margin-top: auto;
  padding-top: 22px;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
}

.project.is-featured {
  grid-column: 1 / -1;
  flex-direction: row;
}

.project.is-featured .project-cover {
  flex: 0 0 44%;
  height: auto;
  min-height: 300px;
  border-bottom: 0;
  border-right: 1px solid var(--line);
}

.project.is-featured .project-body {
  padding: 32px 32px 30px;
}

.project.is-featured h3 {
  font-size: 1.45rem;
}

@media (max-width: 760px) {
  .projects {
    grid-template-columns: minmax(0, 1fr);
  }

  .project.is-featured {
    flex-direction: column;
  }

  .project.is-featured .project-cover {
    flex: none;
    height: 168px;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .project.is-featured .project-body {
    padding: 24px 24px 26px;
  }
}

/* 03: words around a globe (a plain list without JavaScript) */
.globe-words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-soft);
}

.globe.is-3d .globe-words {
  position: absolute;
  inset: 0;
  display: block;
}

.globe.is-3d .globe-words li {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: color 0.25s var(--ease);
  will-change: transform, opacity;
}

.globe.is-3d .globe-words li:hover {
  color: var(--text);
}

/* 04: contact (email, then the links) */
.contact {
  padding-bottom: 120px;
}

.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 28px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 600px) {
  .exp {
    padding-top: 88px;
  }
}

/* Headings focused by the in-page links (focus is moved for keyboard users, no ring needed) */
.hero h1:focus,
.exp h2:focus {
  outline: none;
}
