:root {
  --bg: #0A1120;
  --surface: #121A2C;
  --ink: #ECEAE3;
  --ink-soft: #ADB5C4;
  --ink-faint: #6E7887;
  --border: #232D42;
  --teal: #199e70;
  --amber: #c98500;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 28px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header — R9.8: slim, responsive */
#site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex: 0 0 auto;
}
#site-header .brand-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
#site-header .brand {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
#site-header .role {
  font-size: 12.5px;
  color: var(--teal);
}
#site-header .role-next {
  color: var(--amber);
}
#site-header .role-next em {
  font-style: normal;
  color: var(--ink-faint);
}
#site-header .intro {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  max-width: 480px;
}
#site-header .hint {
  font-size: 12.5px;
  color: var(--ink-faint);
  flex: 0 0 auto;
  align-self: flex-start;
}

/* Graph — R9.8: ~75% of remaining viewport height */
#graph-panel {
  flex: 0 0 75vh;
  height: 75vh;
  width: 100%;
  position: relative;
}
#cy {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 50% 30%, #0E1830 0%, #0A1120 70%);
  position: relative;
}
/* Real DOM <img> icons overlaid on top of Cytoscape's canvas nodes — sidesteps
   a canvas background-image re-rasterization bug seen on zoom/pan (2026-08-22). */
#node-icons-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
#node-icons-layer img {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border-radius: 50%;
}

/* View tabs — R10: switch Graph/List without scrolling. Pushed to the far right
   of the header (Marc's request 2026-08-22), "liquid glass" sliding indicator. */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}
.view-tabs {
  position: relative;
  display: flex;
  gap: 2px;
  background: rgba(18, 26, 44, 0.42);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 100px;
  padding: 4px;
  box-shadow:
    inset 0 1.5px 0 rgba(255,255,255,0.09),
    inset 0 -1px 4px rgba(0,0,0,0.2),
    0 6px 20px rgba(0,0,0,0.3);
  transition: box-shadow 200ms ease, border-color 200ms ease;
}
.view-tabs:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow:
    inset 0 1.5px 0 rgba(255,255,255,0.14),
    inset 0 -1px 4px rgba(0,0,0,0.2),
    0 8px 24px rgba(0,0,0,0.35);
}
.view-tabs-glow {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  border-radius: 100px;
  background:
    linear-gradient(165deg, rgba(255,220,160,0.98) 0%, rgba(230,175,80,0.94) 38%, rgba(178,108,8,0.92) 100%);
  border: 1px solid rgba(255,255,255,0.3);
  box-shadow:
    0 3px 10px rgba(201,133,0,0.5),
    0 1px 2px rgba(0,0,0,0.2),
    inset 0 1.5px 1px rgba(255,255,255,0.75),
    inset 0 -2px 3px rgba(110,64,0,0.4);
  /* No backdrop-filter here — this pill is opaque-ish already; stacking a
     second blur under the .view-tabs container's own blur was producing a
     "ghost double indicator" artifact (reported 2026-08-23). */
  /* Single animation now, not two competing ones (2026-08-23): a second,
     independently-timed scale-pulse used to run alongside this slide —
     different durations/easings on the same tiny element produced an
     intermittent wobble that was hard to capture in a still screenshot.
     One transition, one spring, nothing else touches transform here. */
  transition: left 320ms cubic-bezier(.34,1.32,.64,1), width 320ms cubic-bezier(.34,1.32,.64,1);
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.view-tabs-glow::after {
  /* thin glassy specular streak near the top edge */
  content: '';
  position: absolute;
  top: 1px; left: 8%;
  width: 84%; height: 38%;
  border-radius: 100px;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0));
}
.view-tab {
  position: relative;
  z-index: 1;
  background: none;
  border: none;
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 12.5px;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 200ms ease;
}
.view-tab.active { color: #0A1120; font-weight: 600; }
.view-tab:not(.active):hover { color: var(--ink); }
.view-tab:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .view-tabs-glow { transition: none; }
}

/* Graph/List cross-fade (R9.9) — scale + blur settle, not a flat opacity cut */
#graph-panel, #accessible-content {
  opacity: 1;
  transform: scale(1);
  filter: blur(0px);
  transition:
    opacity 340ms cubic-bezier(.4,0,.2,1),
    transform 340ms cubic-bezier(.34,1.2,.4,1),
    filter 280ms ease;
}
.view-fade-in { opacity: 0 !important; transform: scale(1.025) !important; filter: blur(5px) !important; }
.view-fade-out { opacity: 0 !important; transform: scale(0.975) !important; filter: blur(5px) !important; }
@media (prefers-reduced-motion: reduce) {
  #graph-panel, #accessible-content { transition: opacity 120ms linear; }
  .view-fade-in, .view-fade-out { transform: none !important; filter: none !important; }
}

/* Unified button language (2026-08-23) — every clickable control on the site
   shares the same glass-pill base, hover, and press feedback, not just the
   view-tabs. Applies to: side-chips, close buttons, breadcrumb items, tabs. */
.side-chip, .view-tab, .focus-close, .node-card-close, .focus-breadcrumb button,
.card-link, .skip-link {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  backdrop-filter: blur(6px) saturate(130%);
  -webkit-backdrop-filter: blur(6px) saturate(130%);
  transition: transform 120ms cubic-bezier(.34,1.56,.64,1), color 150ms ease,
    border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.side-chip:active, .view-tab:active, .focus-close:active, .node-card-close:active,
.focus-breadcrumb button:active { transform: scale(0.92); }

.focus-close, .node-card-close {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 26, 44, 0.55);
  border: 1px solid var(--border);
  border-radius: 50%;
}
.focus-close:hover, .node-card-close:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(18, 26, 44, 0.8);
}

.focus-breadcrumb button {
  background: rgba(18, 26, 44, 0.65);
  border: 1px solid transparent;
  border-radius: 100px;
  padding: 3px 11px;
}
.focus-breadcrumb button:hover {
  background: rgba(18, 26, 44, 0.85);
  border-color: var(--border);
  color: var(--amber);
}

@media (prefers-reduced-motion: reduce) {
  .side-chip, .view-tab, .focus-close, .node-card-close, .focus-breadcrumb button {
    transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
  }
  .side-chip:active, .view-tab:active, .focus-close:active, .node-card-close:active,
  .focus-breadcrumb button:active { transform: none; }
}

/* Bounce when the focus-card content swaps (drilling in / going back) */
@keyframes card-bounce-in {
  0% { transform: scale(0.9) translateY(6px); opacity: 0.3; }
  55% { transform: scale(1.035) translateY(-2px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.focus-card.swap { animation: card-bounce-in 360ms cubic-bezier(.34,1.56,.64,1); }
@keyframes side-bounce-in {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.side-chip.swap { animation: side-bounce-in 320ms cubic-bezier(.34,1.56,.64,1) backwards; }
@media (prefers-reduced-motion: reduce) {
  .focus-card.swap { animation: none; }
  .side-chip.swap { animation: none; }
}

#accessible-content[hidden], #graph-panel[hidden] { display: none; }

@media (max-width: 600px) {
  #site-header { padding: 12px 16px; }
  #site-header .hint { display: none; }
  #graph-panel { flex-basis: 75vh; height: 75vh; }
}

/* Tooltip */
.tooltip {
  display: none;
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink-soft);
  max-width: 220px;
  box-shadow: var(--shadow);
}
.tooltip strong { color: var(--ink); display: block; margin-bottom: 2px; }

/* R9.5 (revised): clicking a node opens a centered focus view — the card takes
   the middle of the screen, connected nodes appear as side options so the user
   can keep drilling in, giving a sense of continuity instead of a dead-end popup.
   R9.9: smooth, reduced-motion aware. */
.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(6, 9, 16, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease, background 220ms ease;
}
.focus-overlay.open {
  background: rgba(6, 9, 16, 0.82);
  pointer-events: auto;
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .focus-overlay { transition: opacity 120ms linear; }
}

.focus-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12.5px;
  color: var(--ink-faint);
  margin-bottom: 18px;
  max-width: 90vw;
}
.focus-breadcrumb button {
  /* background/border/padding come from the unified glass-button rule above —
     duplicating them here previously overrode that styling (found 2026-08-23). */
  color: var(--ink-faint);
  font-size: 12.5px;
  cursor: pointer;
}
.focus-breadcrumb button:hover,
.focus-breadcrumb button:focus-visible { color: var(--amber); }
.focus-breadcrumb .crumb-sep { color: var(--border); }
.focus-breadcrumb .crumb-current { color: var(--ink); }

.focus-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  width: 100%;
  max-width: 1240px;
}
.focus-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 200px;
  flex: 0 0 auto;
  padding-top: 8px;
}
.focus-side-left { align-items: flex-end; }
.focus-side-right { align-items: flex-start; }
.focus-side .side-label {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 2px;
}
.side-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 26, 44, 0.8);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 7px 14px;
  color: var(--ink-soft);
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  max-width: 100%;
}
.side-chip:hover, .side-chip:focus-visible {
  border-color: var(--amber);
  color: var(--ink);
  transform: translateX(0) scale(1.03);
}
.side-chip.back { color: var(--teal); }

.focus-card {
  position: relative;
  width: min(680px, 90vw);
  max-height: min(680px, 84vh);
  /* Glass, extended here per Marc's 2026-08-23 request — but kept high-opacity
     (0.96) on purpose: blur reads as "glass", transparency is what hurts
     legibility, so opacity stays high while the blur still shows through. */
  background: rgba(18, 26, 44, 0.96);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.06);
  padding: 32px 34px 28px;
  overflow-y: auto;
  transform: scale(0.92);
  opacity: 0;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), opacity 200ms ease;
}
.focus-overlay.open .focus-card { transform: scale(1); opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .focus-card { transition: opacity 120ms linear; transform: none !important; }
}

.focus-card h2 {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 600;
  font-size: 28px;
  margin: 0 0 10px;
  color: var(--ink);
}
.focus-card .teaser { color: var(--amber); font-size: 15.5px; margin: 0 0 16px; line-height: 1.5; }
.focus-card p { color: var(--ink-soft); font-size: 16px; line-height: 1.65; }
.focus-card .meta { color: var(--ink-faint); font-size: 13.5px; margin-top: 14px; }
.focus-card .metric { color: var(--amber); font-weight: 600; font-size: 15px; margin-top: 10px; }
.focus-card .status-badge {
  display: inline-block;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 999px;
  padding: 3px 10px;
  margin: 0 0 14px;
}
.focus-card .card-links { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.focus-card .card-link { display: inline-block; color: var(--teal); text-decoration: none; font-size: 13.5px; }
.focus-card .card-link:hover { text-decoration: underline; }
.focus-card .skill-group-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 16px 0 6px;
}
.focus-card .skill-group-label:first-of-type { margin-top: 6px; }
.focus-card .skills-list, #accessible-content .skills-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.focus-card .skills-list li, #accessible-content .skills-list li {
  font-size: 13px;
  color: var(--ink-soft);
  border-left: 2px solid var(--border);
  padding-left: 10px;
}
.focus-card .skills-list strong, #accessible-content .skills-list strong {
  display: block;
  color: var(--ink);
  font-size: 13.5px;
  margin-bottom: 1px;
}
.focus-card .skills-list span { display: block; }
.focus-card .job { margin-bottom: 14px; }
.focus-card .job-role { color: var(--ink); font-weight: 600; font-size: 14.5px; }
.focus-card .job-meta { color: var(--ink-faint); font-size: 12px; margin: 2px 0 6px; }
.focus-card .job ul { margin: 0; padding-left: 18px; color: var(--ink-soft); font-size: 13.5px; }
.focus-card .job li { margin-bottom: 3px; }
.card-diagram-fig { margin: 16px 0; }
.card-diagram {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.card-diagram-fig figcaption {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 6px;
  text-align: center;
}
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }

.focus-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}
.focus-close:hover { color: var(--ink); }

@media (max-width: 760px) {
  .focus-layout { flex-direction: column; align-items: center; }
  .focus-side { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .focus-side-left, .focus-side-right { align-items: center; justify-content: center; order: 3; }
  .focus-card { order: 1; }
}

/* Accessibility (R10) */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--amber);
  color: #0A1120;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  z-index: 50;
  transition: top 150ms ease;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* R10.1/R10.2: real semantic fallback — not display:none, styled plainly below the graph */
#accessible-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
#accessible-content section {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
#accessible-content h2 {
  font-size: 20px;
  color: var(--ink);
  margin: 0 0 6px;
}
#accessible-content .teaser { color: var(--amber); font-size: 14px; margin: 0 0 10px; }
#accessible-content p { color: var(--ink-soft); font-size: 15px; margin: 0 0 8px; }
#accessible-content .meta { color: var(--ink-faint); font-size: 13px; }
#accessible-content .metric { color: var(--amber); font-weight: 600; font-size: 13.5px; }
#accessible-content a { color: var(--teal); }
#accessible-content ul { color: var(--ink-soft); font-size: 14px; padding-left: 20px; }
#accessible-content .intro { font-size: 16px; color: var(--ink); padding: 24px 0 8px; }
#accessible-content .sub-entry { margin: 14px 0 14px 18px; padding-left: 14px; border-left: 2px solid var(--border); }
#accessible-content .job { margin: 10px 0 16px; }
#accessible-content .job-role { color: var(--ink); font-weight: 600; font-size: 15px; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
