/* Shared UI components — nav, timeline, project list, media */
/* Quiet chrome: content louder than decoration */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  min-height: var(--nav-h);
  /* Match .page horizontal inset so nav shares the content shell */
  padding: var(--space-4) max(var(--page-gutter), calc((100% - var(--page-max)) / 2));
  background: transparent;
  pointer-events: none;
}

/*
  Fixed nav scrim — same field + glow as html (not flat --bg), then soft-mask
  so resume paper can pass under without a black cutoff seam.
*/
.site-header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: calc(var(--nav-h) + var(--space-6));
  background-color: var(--bg);
  background-image: var(--field);
  background-attachment: fixed;
  background-repeat: no-repeat;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 72%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  /* Tight gaps between labels; equal inset restores the wider timeline rail
     and centers About…CV within that span (not the full page). */
  gap: var(--space-2) var(--nav-gap-tight);
  margin-left: auto;
  pointer-events: auto;
  max-width: 100%;
  --nav-gap-tight: clamp(1.35rem, 2.8vw, 2.35rem);
  --nav-gap-rail: clamp(2.5rem, 5.5vw, 5rem);
  /*
    Old lead-spacer + gap before About = 3×rail − 3×tight.
    Split that as equal inline padding so the cluster sits in the rail center.
    Extra +2rem/side replaces the old RESUME-width last slot: keeps the
    timeline wide enough for “Principal Animation Engineer” without making
    the CV label look oddly spaced from Reel.
  */
  padding-inline: calc(
    (3 * var(--nav-gap-rail) - 3 * var(--nav-gap-tight)) / 2 + 2rem
  );
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.25rem 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--chrome-size);
  font-weight: var(--chrome-weight);
  letter-spacing: var(--chrome-tracking);
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--ease);
}

/*
  Nav labels are short uppercase chrome — give each a slightly wider
  hit target so CV (and the others) are easy to catch with a mouse.
  Extra hit area via ::after so the timeline rail width stays put.
*/
.nav-actions .btn {
  position: relative;
}

.nav-actions .btn::after {
  content: "";
  position: absolute;
  inset: -0.35rem -0.7rem;
}

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

.btn[aria-current="page"] {
  color: var(--accent);
  cursor: default;
  pointer-events: none;
}

.page {
  width: min(100% - (var(--page-gutter) * 2), var(--page-max));
  margin: 0 auto;
  padding: var(--space-7) 0 var(--space-8);
  animation: page-in 0.4s ease both;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(0.55rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/*
  Item expand — GitHub / modern-details pattern (Builder / Stefan Judis):
  slide height on ::details-content. No opacity tween (that was the blip).
*/
:root {
  interpolate-size: allow-keywords;
}

.timeline details::details-content,
details[data-project]::details-content {
  overflow: hidden;
  height: 0;
  transition:
    height 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    content-visibility 0.4s allow-discrete;
}

.timeline details[open]::details-content,
details[data-project][open]::details-content {
  height: auto;
}

@media (prefers-reduced-motion: reduce) {
  .timeline details::details-content,
  details[data-project]::details-content {
    transition: none;
  }
}

.lede {
  max-width: 32rem;
  color: var(--muted);
  font-size: var(--text-md);
}

.section-label {
  margin-bottom: var(--space-5);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}

.timeline-employer {
  margin: 0 0 var(--space-4);
  /* Match timeline chevron: summary::after { right: 0.2rem } */
  padding-right: 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-align: right;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.timeline-bullets {
  margin: 0;
  padding-left: 0;
  list-style: none;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.65;
}

.timeline-bullets li {
  margin-bottom: 0.4em;
}

.timeline-bullets li:last-child {
  margin-bottom: 0;
}

.timeline-item {
  position: relative;
  padding: 0 0 var(--space-6) var(--space-5);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -0.28rem;
  top: 0.45rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
  z-index: 1;
}

.timeline-item details {
  width: 100%;
}

.timeline-summary {
  list-style: none;
  display: grid;
  grid-template-columns: 6.25rem minmax(0, 1fr);
  column-gap: var(--space-4);
  align-items: baseline;
  width: 100%;
  /* Reserved control column for the chevron (design-system pattern) */
  padding-right: 1.85rem;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.timeline-summary::-webkit-details-marker {
  display: none;
}

.timeline-summary::after {
  content: "";
  position: absolute;
  right: 0.2rem;
  top: 0.45rem;
  width: 0.35rem;
  height: 0.35rem;
  border-right: 1.5px solid var(--muted-dim);
  border-bottom: 1.5px solid var(--muted-dim);
  opacity: 0.85;
  transform: rotate(45deg);
  transition: border-color var(--ease), transform var(--ease), opacity var(--ease);
  pointer-events: none;
}

.timeline-summary:hover::after,
.timeline-item details[open] > .timeline-summary::after {
  border-color: var(--accent);
  opacity: 1;
}

.timeline-item details[open] > .timeline-summary::after {
  top: 0.6rem;
  transform: rotate(225deg);
}

.timeline-summary:hover .timeline-role {
  color: var(--accent);
}

.timeline-dates {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted-dim);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.timeline-copy {
  min-width: 0;
}

/* Growth-at-one-studio: position loudest, then game, company quiet. */
.timeline-role {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--fg);
  transition: color var(--ease);
}

.timeline-project {
  display: block;
  margin: 0.12rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
}

.timeline-org {
  display: block;
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.45;
  color: var(--muted-dim);
}

@media (min-width: 1200px) {
  .timeline-project,
  .timeline-role {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.timeline-body {
  grid-column: 1 / -1;
  padding: var(--space-3) 0 0;
  margin-left: calc(6.25rem + var(--space-4));
}

.timeline-detail {
  margin: 0;
  max-width: none;
  width: 100%;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.7;
  text-align: left;
  text-wrap: pretty;
}

.portrait {
  display: grid;
  gap: var(--space-2);
  margin-top: 0;
  width: 100%;
}

.portrait-frame {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center top;
  background: rgba(10, 14, 12, 0.45);
}

.project-list {
  list-style: none;
  margin-top: 0;
}

.project-list > li {
  border-bottom: 1px solid var(--line);
}

.project-list > li:last-child {
  border-bottom: 0;
}

.project-list details {
  width: 100%;
}

.project-list summary {
  list-style: none;
  display: grid;
  grid-template-columns: minmax(7rem, 10rem) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: center;
  width: 100%;
  padding: var(--space-5) 1.75rem var(--space-5) 0;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.project-list summary::-webkit-details-marker {
  display: none;
}

.project-list summary::after {
  content: "";
  position: absolute;
  right: 0.15rem;
  top: 50%;
  width: 0.35rem;
  height: 0.35rem;
  margin-top: -0.28rem;
  border-right: 1.5px solid var(--muted-dim);
  border-bottom: 1.5px solid var(--muted-dim);
  opacity: 0.85;
  transform: rotate(45deg);
  transition: border-color var(--ease), transform var(--ease), opacity var(--ease);
  pointer-events: none;
}

.project-list summary:hover::after,
.project-list details[open] > summary::after {
  border-color: var(--accent);
  opacity: 1;
}

.project-list details[open] > summary::after {
  margin-top: -0.1rem;
  transform: rotate(225deg);
}

.project-thumb {
  position: relative;
  min-width: 0;
}

.thumb-video,
.still-frame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: rgba(10, 14, 12, 0.4);
  pointer-events: none;
}

.project-copy {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.project-list summary:hover .project-name {
  color: var(--accent);
}

.project-name {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.015em;
  transition: color var(--ease);
}

.project-blurb {
  max-width: 36rem;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

#rescue-drone .project-blurb {
  max-width: none;
  white-space: nowrap;
}

#keyframe-animation .project-blurb {
  max-width: none;
  white-space: nowrap;
}

.project-body {
  display: grid;
  gap: var(--space-5);
  padding: 0 0 var(--space-6);
}

.project-beat {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-5);
}

.project-beat .media-slot {
  min-width: 0;
  max-width: none;
}

.project-detail {
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
  display: grid;
  align-content: start;
  gap: var(--space-2);
}

.project-detail__title {
  margin: 0;
  color: var(--fg);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.3;
}

.project-detail > p {
  margin: 0;
}

.project-illustration {
  display: grid;
  grid-template-columns: minmax(0, min(25rem, 56%)) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-4);
  margin: 0;
}

.project-illustration__image {
  display: block;
  width: 100%;
  height: auto;
}

.project-illustration > figcaption {
  align-self: center;
  min-width: 0;
  margin: 0;
  color: color-mix(in srgb, var(--muted) 85%, var(--bg));
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: left;
}

.project-diagram {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}

.project-diagram--centered {
  justify-items: center;
  text-align: center;
}

.project-diagram__image {
  display: block;
  width: 100%;
  max-width: 22rem;
  height: auto;
}

.project-diagram > figcaption {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.code-compare {
  display: grid;
  gap: var(--space-2);
}

.code-panel {
  margin: 0;
  min-width: 0;
  background: rgba(10, 14, 12, 0.55);
}

.code-panel figcaption {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.code-compare__file {
  justify-self: end;
  color: var(--muted);
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0;
  text-align: right;
  text-transform: none;
  overflow-wrap: anywhere;
}

.code-panel pre {
  margin: 0;
  padding: 0.4rem 0.65rem;
  overflow-x: auto;
  font-size: 0.68rem;
  line-height: 1.45;
}

.code-panel code {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--muted);
  white-space: pre-wrap;
}

.media-slot__frame {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg);
}

.media-slot__frame img,
.media-slot__frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.media-slot__frame video {
  display: block;
}

#rescue-drone .media-slot--image .media-slot__frame {
  aspect-ratio: auto;
}

#rescue-drone .media-slot--image .media-slot__frame img {
  display: block;
  height: auto;
  object-fit: contain;
}

.media-slot__enlarge {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.media-slot__enlarge:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.media-slot__enlarge-hint {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(15, 20, 18, 0.9);
  color: var(--fg);
  font: var(--text-xs) var(--font);
}

.has-image-viewer {
  overflow: hidden;
}

.image-viewer {
  width: calc(100% - 2rem);
  max-width: none;
  height: calc(100dvh - 2rem);
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
}

.image-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.image-viewer::backdrop {
  background: rgba(0, 0, 0, 0.88);
}

.image-viewer__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.image-viewer__toolbar h2 {
  flex: 1 1 auto;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
}

.image-viewer__toolbar button {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-elevated);
  color: var(--fg);
  font: var(--text-sm) var(--font);
  cursor: pointer;
}

.image-viewer__toolbar button:hover {
  border-color: var(--accent);
}

.image-viewer__stage {
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.image-viewer__stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.image-viewer--actual-size .image-viewer__stage {
  display: block;
}

.image-viewer--actual-size img {
  max-width: none;
  max-height: none;
}

.media-slot__poster {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg);
  pointer-events: none;
}

.media-slot__placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

@media (max-width: 1024px) {
  .project-beat {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
}

@media (max-width: 720px) {
  .project-list summary {
    grid-template-columns: minmax(6rem, 8rem) minmax(0, 1fr);
    gap: var(--space-3);
  }
}

@media (max-width: 520px) {
  #keyframe-animation > summary {
    grid-template-columns: 1fr;
  }

  #keyframe-animation .project-thumb {
    max-width: 12rem;
  }
}

@media (max-width: 480px) {
  #keyframe-animation .project-blurb {
    font-size: clamp(var(--text-xs), 3.85vw, var(--text-sm));
  }

  .project-illustration {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .project-illustration__image {
    max-width: 20rem;
  }

  .project-list summary {
    grid-template-columns: 1fr;
  }

  .project-thumb {
    max-width: 12rem;
  }
}
