/* 100vw so the field also fills a reserved scrollbar gutter in stars mode. the canvas rect,
   not window.innerWidth, is what the scene measures, so projection stays exact either way. */
.starfield {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.vignette {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 100% at 50% 45%, transparent 55%, rgb(0 0 0 / var(--vignette, 0.3)) 100%);
}

.is-catching,
.is-catching body {
  cursor: pointer;
}

.star-ring {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 4;
  width: var(--s, 22px);
  height: var(--s, 22px);
  margin: calc(var(--s, 22px) / -2) 0 0 calc(var(--s, 22px) / -2);
  border: 1px solid rgb(var(--accent-rgb) / 0.75);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.star-ring.is-visible {
  opacity: 1;
}

.focus-pulse {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 4;
  width: var(--s, 40px);
  height: var(--s, 40px);
  margin: calc(var(--s, 40px) / -2) 0 0 calc(var(--s, 40px) / -2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.focus-pulse::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgb(var(--accent-rgb) / 0.4);
  border-radius: 50%;
  /* the pulse's resting frame, so stopping it as the ring fades out never brightens it */
  opacity: 0.55;
}

.focus-pulse.is-visible {
  opacity: 1;
}

/* it only runs while it can be seen */
.focus-pulse.is-visible::before {
  animation: focus-pulse 3.2s ease-in-out infinite;
}

@keyframes focus-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.55;
  }

  50% {
    transform: scale(1.14);
    opacity: 0.18;
  }
}

.card-tether {
  position: fixed;
  inset: 0;
  z-index: 7;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.card-tether.is-visible {
  opacity: 1;
}

.card-tether line {
  stroke: rgb(var(--accent-rgb) / 0.4);
  stroke-width: 1;
}

.card-tether circle {
  fill: rgb(var(--accent-rgb) / 0.75);
}

.stars-ui {
  position: fixed;
  inset: auto 0 0;
  z-index: 6;
  height: 5.5rem;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}

.stars-ui::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6, 8, 11, 0.85), rgba(6, 8, 11, 0));
}

.is-stars .stars-ui {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease 0.2s, visibility 0s;
}

.stars-ui-inner {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: min(var(--wrap), 100% - 2 * var(--gutter));
  height: 100%;
  margin-inline: auto;
  padding-bottom: 1.5rem;
  font: 400 var(--mono-s) / 1.4 var(--font-mono);
}

.stars-ui-inner > * {
  pointer-events: auto;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 1.5rem;
  color: var(--muted);
  white-space: nowrap;
  transform: translateX(-50%);
  transition: opacity 0.5s ease;
}

.hint.is-faded {
  opacity: 0;
}

.browse {
  padding: 0.3rem 0;
  font: inherit;
  color: var(--muted);
  transition: color 0.2s ease;
}

.browse:not(:disabled):hover,
.browse:focus-visible {
  color: var(--text);
}

/* a pinned language with nothing to browse */
.browse:disabled {
  opacity: 0.45;
  cursor: default;
}

/* browse and the repo toggle, one unit; the gap between them stays open to the field */
.stars-ui-inner > .browse-group {
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.browse-group > * {
  pointer-events: auto;
}

/* the footer's separator: centered between browse's text and the toggle's (past its padding and border), so the
   toggle sits where it would without it. not a control */
.browse-group > .browse-dot {
  width: calc(0.75rem + 0.6rem + 1px);
  margin-right: calc(-0.6rem - 1px);
  color: var(--muted);
  opacity: 0.6;
  text-align: center;
  pointer-events: none;
}

/* a pull request card has nothing to browse: the group steps aside like the readout */
.stars-ui-inner > .browse-group.is-faded {
  opacity: 0;
}

/* too narrow to sit beside browse without reaching the centered hint: the toggle stacks just above it */
@media (max-width: 880px) {
  .stars-ui-inner > .browse-group {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .browse-group > .browse-dot {
    display: none;
  }
}

/* no pill: the border keeps its space, so pressing or hovering never moves anything */
.repo-only {
  min-height: 24px;
  padding: 0 0.6rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 400 0.6875rem / 1 var(--font-mono);
  color: var(--muted);
  transition: color 0.2s ease;
}

.repo-only:hover,
.repo-only:focus-visible {
  color: var(--text);
}

.repo-only[aria-pressed='true'] {
  color: var(--accent);
}

.readout {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  transition: opacity 0.6s ease;
}

/* a pull request has no month on the time axis, so the readout steps aside with the stars ui's own timing */
.readout.is-faded {
  opacity: 0;
}

.card {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 8;
  width: 22rem;
  will-change: transform;
}

.card:focus {
  outline: none;
}

.card-in {
  transform-origin: 0 50%;
}

.card-body {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(130% 90% at 0% 0%, rgb(var(--lang-rgb, 255 255 255) / 0.09), transparent 58%),
    linear-gradient(var(--surface), var(--surface)),
    rgba(8, 10, 14, 0.78);
  box-shadow: 0 28px 60px -28px rgba(0, 0, 0, 0.85), 0 2px 10px -4px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transform-style: preserve-3d;
}

/* a card taller than the viewport (a short window, large text) scrolls inside its edges, which stay unclipped */
.card-scroll {
  min-height: 0;
  padding: 1.05rem 1.2rem 0.95rem;
  border-radius: 13px;
  overflow: auto;
}

/* a thin top highlight in the language color that fades out to the right */
.card-body::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 14px;
  right: 14px;
  height: 1px;
  background: linear-gradient(90deg, rgb(var(--lang-rgb, 255 255 255) / 0.35), rgb(var(--lang-rgb, 255 255 255) / 0) 75%);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  padding: 0.18rem 0.5rem 0.18rem 0.42rem;
  border: 1px solid rgb(var(--lang-rgb, 255 255 255) / 0.22);
  border-radius: 999px;
  font: 400 0.6875rem / 1.2 var(--font-mono);
  color: var(--text);
}

.lang-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lang);
  box-shadow: 0 0 8px -1px var(--lang);
}

.card-repo {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 400 var(--mono-s) / 1.3 var(--font-mono);
  color: var(--muted);
}

.card-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin: -0.3rem -0.45rem 0 auto;
  border-radius: 8px;
  color: var(--muted);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.card-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.card-close svg {
  width: 12px;
  height: 12px;
}

.card-main {
  margin-top: 0.95rem;
}

.card-date {
  font: 400 0.6875rem / 1.3 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--muted);
}

.card-msg {
  margin-top: 0.35rem;
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.32;
  letter-spacing: -0.018em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.card-stats {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  font: 400 var(--mono-s) / 1.4 var(--font-mono);
}

.card-diff {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.card-diff .add {
  color: var(--accent);
}

.card-diff .del {
  color: var(--muted);
}

.diff-bar {
  display: flex;
  flex: 1 1 auto;
  gap: 2px;
  min-width: 2.5rem;
  max-width: 7rem;
  height: 3px;
}

.diff-bar i {
  display: block;
  min-width: 2px;
  border-radius: 2px;
  flex-basis: 0;
}

.diff-add {
  background: rgb(var(--accent-rgb) / 0.85);
}

.diff-del {
  background: rgba(139, 148, 158, 0.55);
}

.card-files {
  margin-left: auto;
  color: var(--muted);
}

.card-ids {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.85rem;
  margin-top: 0.6rem;
  color: var(--muted);
}

.hash-chip {
  min-width: 4.6rem;
  min-height: 24px;
  padding: 0.12rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  text-align: center;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.hash-chip:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.hash-chip.is-copied {
  border-color: rgb(var(--accent-rgb) / 0.6);
  color: var(--accent);
}

.card-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  font: 400 var(--mono-s) / 1 var(--font-mono);
}

.card-step {
  min-height: 28px;
  padding: 0.35rem 0.5rem;
  margin-left: -0.5rem;
  border-radius: 6px;
  color: var(--muted);
  transition: color 0.2s ease;
}

.card-step + .card-step {
  margin-left: 0;
}

.card-step:hover:not(:disabled) {
  color: var(--text);
}

.card-step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.card-nav .tlink {
  margin-left: auto;
}

/* pull request cards: a metallic gold edge, swept once on open, and nothing else gold */
.card.is-pr {
  --gold-dark: #7a5c26;
  --gold-mid: #b8955a;
  --gold-pale: #efe0b4;
}

.card.is-pr .card-body {
  border-color: transparent;
  box-shadow: 0 28px 60px -28px rgba(0, 0, 0, 0.85), 0 2px 10px -4px rgba(0, 0, 0, 0.5), 0 0 28px -14px rgba(232, 200, 130, 0.18);
}

.card.is-pr .card-body::before {
  display: none;
}

.card.is-pr .card-body::after {
  content: '';
  position: absolute;
  inset: -1px;
  padding: 1px;
  border-radius: 15px;
  pointer-events: none;
  background:
    linear-gradient(105deg, transparent 38%, rgba(255, 246, 220, 0.95) 50%, transparent 62%) no-repeat,
    linear-gradient(135deg, var(--gold-dark) 0%, var(--gold-mid) 24%, var(--gold-pale) 50%, var(--gold-mid) 76%, var(--gold-dark) 100%);
  background-size: 260% 100%, 100% 100%;
  background-position: 160% 0, 0 0;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.card.is-pr.is-shimmering .card-body::after {
  animation: gold-sweep 1.4s cubic-bezier(0.45, 0, 0.25, 1) 0.15s 1 both;
}

@keyframes gold-sweep {
  from {
    background-position: 160% 0, 0 0;
  }

  to {
    background-position: -60% 0, 0 0;
  }
}

.org {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.org-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.card.has-logo .org-logo {
  opacity: 1;
}

.org-mono {
  font: 600 0.8125rem / 1 var(--font-sans);
  color: var(--text);
}

.card.has-logo .org-mono {
  visibility: hidden;
}

.card.is-pr .card-repo {
  color: var(--text);
}

.merged-chip {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.12rem 0.45rem;
  border: 1px solid rgba(232, 208, 150, 0.4);
  border-radius: 999px;
  color: #ead9ad;
  letter-spacing: 0.02em;
}

.pr-num {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0;
  color: var(--muted);
}

.card-tether.is-pr line {
  stroke: rgba(232, 208, 150, 0.4);
}

.card-tether.is-pr circle {
  fill: rgba(239, 224, 180, 0.8);
}

.focus-pulse.is-pr::before {
  border-color: rgba(232, 208, 150, 0.4);
}

.rocket-flyer {
  position: fixed;
  z-index: 30;
  color: var(--accent);
  pointer-events: none;
  will-change: transform;
}

.rocket-flyer svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.is-stars,
.is-peek {
  overflow: hidden;
}

.is-stars .starfield,
.is-peek .starfield {
  pointer-events: auto;
  touch-action: none;
}

.is-stars .topbar::before,
.is-peek .topbar::before {
  opacity: 0;
}

/* without that fade the label sits on bare stars, where muted falls under 4.5:1 */
.is-stars .legend-label,
.is-peek .legend-label {
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  .stars-ui,
  .is-stars .stars-ui,
  .hint,
  .stars-ui-inner > .browse-group,
  .readout,
  .star-ring,
  .focus-pulse,
  .card-tether {
    transition: none;
  }

  .card.is-pr .card-body::after {
    animation: none;
  }

  .focus-pulse::before,
  .focus-pulse.is-visible::before {
    animation: none;
    opacity: 0.35;
  }
}

/* print: the page as a plain document, dark text on white. it sits last in the last stylesheet so it wins,
   and it undoes the narrow rules too, since a narrow page box (a4 with margins is under 720px) matches them */
@media print {
  :root {
    color-scheme: light;
    --bg: #fff;
    --surface: transparent;
    --surface-2: transparent;
    --line: rgb(0 0 0 / 0.14);
    --line-strong: rgb(0 0 0 / 0.3);
    --text: #111;
    --muted: #4a4f55;
    /* over a pinned language's accent, which is written inline on the root */
    --accent: #15803d !important;
    --accent-rgb: 21 128 61 !important;
  }

  html,
  body {
    background: #fff;
    color: var(--text);
  }

  body {
    min-height: 0;
  }

  /* stars mode and a peek lock the page's scroll on screen; on paper it runs its full length */
  .is-stars,
  .is-peek {
    overflow: visible;
  }

  .starfield,
  .sky,
  .vignette,
  .topbar,
  .stars-ui,
  .orbit,
  .rocket,
  .rocket-flyer,
  .skip,
  .card,
  .card-tether,
  .focus-pulse,
  .star-ring,
  .linktree {
    display: none !important;
  }

  /* whatever the reveals, the intro or stars mode left hidden or moved */
  main,
  .site-footer,
  [data-intro],
  [data-reveal],
  [data-reveal-group] > * {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    animation: none !important;
  }

  *,
  *::before,
  *::after {
    text-shadow: none !important;
  }

  .hero {
    display: block;
    min-height: 0;
    padding-block: 0 2rem;
  }

  .hero-inner {
    display: block;
    max-width: 44rem;
    text-align: left;
  }

  .hero-name {
    margin-top: 1.1rem;
    font-size: 2.5rem;
  }

  .hero-kicker {
    margin-top: 0;
    font-size: var(--mono-m);
  }

  .hero-lede {
    display: block;
  }

  .hero-links {
    display: flex;
  }

  .section {
    display: grid;
    padding-block: 1.75rem;
  }

  .rail {
    position: static;
  }

  .rail,
  .sub {
    break-after: avoid;
  }

  .row,
  .pub,
  .tl-item,
  .contact-list > div {
    break-inside: avoid;
  }

  .site-footer {
    display: flex;
    padding-block: 2rem 0;
  }
}
