body {
  margin-inline: max(1em, (100% - 100ch) / 2);
  font: 100%/1.5 system-ui;
}

img {
  max-width: 100%;
  height: auto;
}

nav {
  display: flex;
  gap: 0;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid oklch(80% 3% 200);
}

nav a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: inherit;
  padding: 0.5em 0.25em;
}

:root {
  --color-accent: oklch(70% 25% 240);;
}

nav a.current {
  font-weight: 700;
  border-bottom: 0.4em solid oklch(80% 3% 200);
  padding-bottom: calc(0.5em - 0.4em);
}

nav a:hover {
  border-bottom: 0.4em solid var(--color-accent);
  background-color: oklch(from var(--color-accent) 95% 5% h);
  padding-bottom: calc(0.5em - 0.4em);
}

/* ===== Contact page ===== */
input, textarea, button {
  font: inherit;
}

form {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1em;
  align-items: start;
}

form label {
  display: contents;
}

form input,
form textarea,
form button {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
}

textarea {
  min-height: 6em;
}

form button {
  grid-column: 1 / -1;
}

/* ===== Project page ===== */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15em, 1fr));
  gap: 1em;
}

.projects > article {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;
}

.projects h2 {
  margin: 0;
}

h1 {
  font-size: 300%;
  margin-bottom: 0.5em;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.1;
  text-wrap: balance;
}

/* ===== Resume page ===== */
.resume h2 {
  color: oklch(65% 0.15 240);
  border-bottom: 3px solid oklch(70% 0.12 240);
  padding-bottom: 0.3rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.3rem;
  font-weight: 700;
}

.resume section + section {
  border-top: 1px solid oklch(90% 0 240);
  padding-top: 1.5rem;
}

.resume h3 {
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.subtle {
  color: oklch(45% 0.03 240);
  font-weight: 400;
}

.resume ul {
  margin-top: 0.5rem;
  margin-left: 1.5rem;
}

/* ===== Dark mode ===== */
html {
  color-scheme: light dark;
}

nav {
  --border-color: oklch(50% 10% 200 / 40%);
  border-bottom-color: var(--border-color);
}
nav a:hover {
  background-color: color-mix(in oklch, var(--color-accent), canvas 85%);
}

.color-scheme {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 80%;
  font-family: inherit;
}


/* ===== My GitHub Stats ===== */
html { color-scheme: light dark; }

#profile-stats {
  margin-block: 2.5rem;
}

#profile-stats h3 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 800;
}

#profile-stats dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 2rem;
  row-gap: 0.5rem;
  align-items: center;
  margin: 0;
}

#profile-stats dt, #profile-stats dd {
  text-align: center;
}

#profile-stats dt {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: color-mix(in oklch, canvastext 50%, canvas 50%);
}

#profile-stats dd {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: color-mix(in oklch, canvastext 90%, canvas 10%);
}

@media (max-width: 800px) {
  #profile-stats dl {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 1rem;
  }
  #profile-stats dd {
    font-size: 1.5rem;
  }
}


/* ===== Projects Pie Plot ===== */
#projects-pie-plot{
  width: 100%;
  max-width: 260px;
  height: auto;
  aspect-ratio: 1 / 1; 
  overflow: visible;
}


/* Legend for Pie Plot */
.legend{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9em, 1fr));
  gap: .5rem 1rem;
  padding: .75rem 1rem;
  border: 1px solid #ddd;
  border-radius: .5rem;
}

.legend-item{
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 9em;
  font-size: .95rem;
}

.legend-item .swatch{
  width: .9rem;
  height: .9rem;
  background: var(--color);
  border-radius: 2px;
  display: inline-block;
}

.legend-item em{
  font-style: normal;
  opacity: .7;
}

.viz{
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.viz .legend{ flex: 1; }

/* ===== Search Bar ===== */
.searchBar {
  width: 100%;
  padding: .6rem .9rem;
  border: 1px solid var(--color-border, #d0d7de);
  border-radius: .4rem;
  margin-block: 1rem 2rem;
}

/* ===== Pie Plot Interactivity ===== */
#projects-pie-plot path {
  cursor: pointer;
  transition: 300ms;
}

#projects-pie-plot:has(path:hover) path:not(:hover) {
  opacity: 0.5;
}

.legend .legend-item.selected { 
  outline: 1px solid var(--color);
  border-radius: 6px;
  padding: 2px 6px;
}

#projects-pie-plot path.selected {
  fill: oklch(60% 0.2 0) !important;
  stroke: black;
  stroke-width: 2px;
}

.legend .legend-item.selected {
  --color: oklch(60% 0.2 0) !important;
}

.legend .legend-item .swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color);
  display: inline-block;
  margin-right: .5rem;
}


/* ===== Meta summary stats ===== */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 60px;
  margin-top: 32px;
}

.stats dt,
.stats dd {
  display: block;
  margin: 0;
  padding: 0;
}

.stats dt {
  font-size: 11px;
  color: rgba(0,0,0,.45);
  margin-bottom: 4px;
}

.stats dd {
  font-size: 22px;
  font-weight: 400;
  line-height: 1.2;
}

#stats-wrapper {
  border: 1.5px solid #e1e4e8;
  border-radius: 12px;
  padding: 1.2rem 2rem;
  margin-top: 1rem;
  background: var(--color-bg);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

/* Title: Summary */
#stats-wrapper h2 {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  margin-top: 0.6rem;
}


.gridlines line {
  stroke: #ccc;
  stroke-opacity: 0.4;
}

.gridlines path {
  display: none;
}

/* ===== Scatter Plot Tooltip ===== */
dl.info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .25rem 1rem;
  margin: 0;
}
dl.info > dt {
  color: var(--muted-foreground, #6b7280);
  font-size: .9rem;
  font-weight: 500;
}
dl.info > dd { margin: 0; }

.tooltip {
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 999;
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
  padding: .75rem 1rem;
  pointer-events: none;
  transition: opacity .25s ease, visibility .25s ease;
}

dl.info[hidden]:not(:hover, :focus-within) {
  opacity: 0;
  visibility: hidden;
}

circle {
  transition: 200ms;
  transform-origin: center;
  transform-box: fill-box;
}
circle:hover { transform: scale(1.5); }


/* ===== Scatter Plot Brush Selection ===== */
.selection {
  fill-opacity: 0.1;
  stroke: black;
  stroke-opacity: 0.7;
  stroke-dasharray: 5 3;
  animation: marching-ants 2s linear infinite;
  rx: 8px;
}
@keyframes marching-ants { to { stroke-dashoffset: -8; } }

circle.selected {
  fill: #ff6bb6;
}


.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto;
  grid-auto-flow: column;
  gap: 0.6rem;
  text-align: center;
}

.lang .name {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: .4rem;
}

.lang .value {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: .2rem;
}

.lang .pct {
  font-size: 1.4rem;
  opacity: .8;
}

.lang.is-zero { opacity: .45; }

/* ===== Project Link Button ===== */
.project-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #4f46e5;
  padding: 4px 10px;
  border-radius: 8px;
  background: #eef2ff;
  text-decoration: none;
  transition: 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.project-link:hover {
  background: #e0e7ff;
  transform: translateX(3px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

.project-link::after {
  content: "➜";
  font-size: 1.1rem;
}

/* ===== Scatter Plot Animation ===== */
circle {
  transition: all 300ms ease;
}

@starting-style {
  circle {
    r: 0;
  }
}

/* ===== Recently Edited Files List ===== */
#files {
  display: grid;
  grid-template-columns: 1fr 4fr;
}

#files > div {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
}

#files dt {
  grid-column: 1;
}

#files dt code {
  font-weight: bold;
}

.loc {
  display: flex;
  width: 0.5em;
  aspect-ratio: 1;
  background: steelblue;
  border-radius: 50%;
}

#files dd {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  align-content: start;
  gap: 0.15em;
  padding-top: 0.6em;
  margin-left: 0;
}

/* ===== Scatter Plot with Scrolly-Telling ===== */
#scrolly-1 {
  position: relative;
  display: flex;
  gap: 1rem;
}

#scrolly-1 > * {
  flex: 1;
}

#scatter-story {
  position: relative;
}

#scatter-plot {
  position: sticky;
  top: 0;
  left: 0;
  bottom: auto;
  height: 50vh;
}

#scatter-story .step {
  margin-bottom: 2rem;
  line-height: 1.6;
  font-size: 1rem;
  max-width: 38rem;
}