/* Place custom css here */

:root {
  --citation-color: var(--content-secondary);
  --citation-tooltip-bg: var(--background);
  --citation-tooltip-border: var(--content-secondary);
}

.dark {
  --citation-color: var(--content-secondary);
  --citation-tooltip-bg: var(--background);
  --citation-tooltip-border: var(--content-secondary);
}

.citation-group {
  display: inline;
  color: inherit;
}

.citation-group--parenthetical {
  display: inline;
  white-space: normal;
}

.citation-group__leading,
.citation-group__separator,
.citation-group__trailing {
  display: inline;
  color: inherit;
}

.citation-group__leading,
.citation-group__trailing {
  white-space: nowrap;
}

.citation-group__separator {
  white-space: normal;
}

.citation-group__paren {
  color: inherit;
}

.citation-ref {
  position: relative;
  display: inline-flex;
  gap: 0.25rem;
  align-items: baseline;
  color: var(--citation-color);
}

.citation-ref__text {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  outline: none;
  cursor: pointer;
}

.citation-ref__text:focus-visible {
  outline: 1px solid var(--content-secondary);
  outline-offset: 2px;
}

.citation-tooltip {
  display: block;
  position: fixed;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  width: max-content;
  max-width: min(28rem, 90vw);
  padding: 16px 20px;
  background: var(--bg-secondary, #1a1a1a);
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  color: var(--content-primary);
  font-size: 0.875rem;
  line-height: 1.5;
  z-index: 1000;
  text-align: left;
  white-space: normal;
  transition: opacity 150ms ease;
}

:root:not(.dark) .citation-tooltip {
  background: var(--bg, #fff);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

.citation-ref:hover .citation-tooltip,
.citation-ref:focus-within .citation-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.citation-ref.tooltip-hidden .citation-tooltip {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.citation-tooltip__meta {
  font-family: var(--mono-font);
  font-size: 0.75rem;
  /* letter-spacing: 0.02em; */
  display: block;
  color: var(--content-secondary);
  margin-bottom: 0.35rem;
}

.citation-tooltip__title {
  display: block;
  font-style: italic;
  font-weight: 400;
  color: var(--content-primary);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.citation-tooltip__source {
  display: block;
  font-size: 0.8rem;
  color: var(--content-secondary);
  margin-top: 0.25rem;
}

@media (prefers-reduced-motion: reduce) {
  .citation-tooltip {
    transition: none;
  }
}

/* Ensure dark-mode SVGs remain legible when reused for light theme */
.light .img-light img[src$="perf_dark.svg"],
.light .img-light img[src$="broadcast.svg"],
.light .img-light img[src$="perf_chunks.svg"],
.light .img-light img[src$="vary_chunk_size.svg"],
.light .img-light img[src$="multicore_v_chunks.svg"] {
  background-color: var(--content-primary);
}

/* Allow opting into wrapped code fences via {.wrap} or {data-wrap=true} */
.highlight.wrap,
.highlight[data-wrap] {
  overflow-x: auto;
}

.highlight.wrap pre,
.highlight[data-wrap] pre,
pre.wrap,
pre[data-wrap] {
  white-space: pre-wrap;
}

.highlight.wrap code,
.highlight[data-wrap] code,
pre.wrap code,
pre[data-wrap] code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.highlight.wrap .line,
.highlight[data-wrap] .line {
  display: block;
}

.highlight.wrap .line .cl,
.highlight[data-wrap] .line .cl {
  display: block;
}

/* Trio image layout */
.image-trio {
  --trio-top-width: calc((100% - var(--trio-col-gap))/2);
  --trio-col-gap: clamp(1rem, 1vw, 2.5rem);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "top top"
    "left right"
    "caption caption";
  column-gap: 1vw;
  row-gap: 1vw;
  align-items: start;
  justify-items: stretch;
  width: 100%;
  margin: 0 auto;
}

.image-trio > figure {
  margin: 0;
}

.image-trio__figure--top {
  grid-area: top;
  justify-self: center;
  width: var(--trio-top-width);
}

.image-trio__figure--bottom-left {
  grid-area: left;
}

.image-trio__figure--bottom-right {
  grid-area: right;
}

.image-trio__figure--bottom-left,
.image-trio__figure--bottom-right {
  width: 100%;
}

.image-trio__global-caption {
  grid-area: caption;
  grid-column: 1 / -1;
  width: 100%;
}

.image-trio__global-caption-text {
  color: var(--content-secondary);
  font-size: var(--caption-font-size);
  text-align: center;
  padding-left: var(--caption-padding);
  padding-right: var(--caption-padding);
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.image-trio__global-caption-text > * {
  margin-top: 0;
  margin-bottom: 0;
}

@media (max-width: 720px) {
  .image-trio {
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "left"
      "right"
      "caption";
    column-gap: 0;
    row-gap: 1rem;
  }

  .image-trio__figure--top {
    width: 100%;
    justify-self: stretch;
  }
}

.img-full .caption-container {
  display: block;
  justify-content: center;
  text-align: center;
}

/* Code line highlighting - added/changed/removed */
.chroma .line.hl-added {
  background-color: rgba(142, 192, 124, 0.25);
}

.chroma .line.hl-changed {
  background-color: rgba(250, 189, 47, 0.25);
}

.chroma .line.hl-removed {
  background-color: rgba(251, 73, 52, 0.25);
}

/* Slightly stronger colors for light mode */
.light .chroma .line.hl-added {
  background-color: rgba(121, 116, 14, 0.3);
}

.light .chroma .line.hl-changed {
  background-color: rgba(181, 118, 20, 0.35);
}

.light .chroma .line.hl-removed {
  background-color: rgba(157, 0, 6, 0.25);
}

/* Reference highlight when clicking citation */
.ref-highlight {
  background-color: rgba(215, 153, 33, 0.25); /* --yellow1 */
}

.dark .ref-highlight {
  background-color: rgba(250, 189, 47, 0.2); /* --yellow2 */
}

/* Reference backlink */
.ref-backlink {
  color: var(--content-secondary);
  text-decoration: none;
  margin-left: 0.3em;
  font-size: 0.85em;
}

.ref-backlink:hover {
  color: var(--content-primary);
}

/* CV Page Styles */
.cv-container {
  max-width: var(--main-width);
  margin: 0 auto;
}

.cv-intro {
  margin-bottom: 2rem;
  color: var(--content-secondary);
}

.cv-section {
  margin-bottom: 3rem;
}

.cv-section h2 {
  font-size: 1.4em;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--code-border);
}

.cv-entries {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.cv-entry {
  position: relative;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.cv-logo-container {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 6px;
}

.cv-logo-bg--light {
  background: #fcfbfa; /* light mode --background */
  padding: 4px;
}

.cv-logo-bg--dark {
  background: #141413; /* dark mode --background */
  padding: 4px;
}

.cv-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.cv-logo-container:not([class*="cv-logo-bg"]) .cv-logo {
  width: 48px;
  height: 48px;
}

/* Dark logo hidden by default (light mode) */
.cv-logo--dark {
  display: none;
}

/* In dark mode: show dark logo, hide light logo if dark exists */
.dark .cv-logo--dark {
  display: block;
}

.dark .cv-logo-container:has(.cv-logo--dark) .cv-logo--light {
  display: none;
}

/* Invert dark icons in dark mode */
.dark .cv-logo--invert {
  filter: invert(1);
}

.cv-entry-content {
  flex: 1;
  min-width: 0;
}

.cv-entry-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.cv-entry-title h3 {
  font-size: 1.1em;
  margin: 0;
  font-weight: 600;
}

.cv-entry-title h3 a {
  text-decoration: none;
}

.cv-entry-title h3 a:hover {
  text-decoration: underline;
}

.cv-company {
  color: var(--content-secondary);
  font-size: 0.95em;
}

.cv-entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85em;
  color: var(--content-secondary);
}

.cv-date {
  font-family: "Valkyrie B Caps", var(--body-font);
  font-variant-numeric: tabular-nums;
  font-size: 0.85em;
}

.cv-location::before {
  content: "·";
  margin-right: 0.5rem;
}

.cv-summary {
  margin: 0.5rem 0;
  font-size: 0.95em;
  line-height: 1.5;
}

.cv-highlights {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
  font-size: 0.95em;
}

.cv-highlights li {
  margin-bottom: 0.25rem;
}

.cv-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.cv-keyword {
  font-family: var(--mono-font);
  font-size: 0.75em;
  padding: 0.2rem 0.5rem;
  background: var(--code-background);
  border-radius: 4px;
  color: var(--content-secondary);
}

.cv-skills {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.cv-skill-group h4 {
  font-size: 1em;
  margin: 0 0 0.5rem 0;
  font-weight: 500;
}

@media screen and (min-width: 640px) {
  .cv-entry-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }

  .cv-entry-meta {
    text-align: right;
    flex-direction: column;
    gap: 0;
  }

  .cv-location::before {
    content: none;
  }
}

/* Active users widget */
.header-nav {
  width: 100%;
  justify-content: flex-end;
}

.active-users {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: "JetBrainsMono Nerd Font Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: calc(var(--nav-scale) * 0.6);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--content-secondary, var(--fg-faint));
  margin-right: auto;
}

.active-users__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: active-users-pulse 2.2s ease-out infinite;
}

.active-users__label {
  font-variant-caps: all-small-caps;
}

.active-users__count {
  font-variant-caps: all-small-caps;
  color: var(--content-primary, var(--fg));
}

.active-users--error {
  opacity: 0.6;
}

@keyframes active-users-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    opacity: 0.9;
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    opacity: 0.6;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    opacity: 0.8;
  }
}

@media (max-width: 640px) {
  .active-users__label {
    display: none;
  }
}
