:root {
  --color-accent: oklch(85% 10% 140);
  --border-color: oklch(75% 8% 140 / 50%);
  accent-color: var(--color-accent);
}

/* THEME COLORS */
html.light {
  background-color: oklch(97% 4% 140);
  color: oklch(20% 0% 0);
  --color-accent: oklch(85% 10% 140);
  --tooltip-bg-light: oklch(97% 4% 140 / 95%);
  --tooltip-text-light: oklch(30% 4% 140);
  --border-color: oklch(75% 8% 140 / 50%);
}

html.dark {
  background-color: oklch(20% 4% 140);
  color: oklch(90% 4% 140);
  --color-accent: oklch(85% 10% 140);
  --tooltip-bg-dark: oklch(20% 4% 140 / 95%);
  --tooltip-text-dark: oklch(90% 4% 140);
  --border-color: oklch(75% 8% 140 / 50%);
}

@media (prefers-color-scheme: dark) {
  html.auto {
    background-color: oklch(20% 4% 140);
    color: oklch(90% 4% 140);
    --color-accent: oklch(85% 10% 140);
    --tooltip-bg-dark: oklch(20% 4% 140 / 95%);
    --tooltip-text-dark: oklch(90% 4% 140);
    --border-color: oklch(75% 8% 140 / 50%);
  }
}

@media (prefers-color-scheme: light) {
  html.auto {
    background-color: oklch(97% 4% 140);
    color: oklch(30% 4% 140);
    --color-accent: oklch(85% 10% 140);
    --tooltip-bg-light: oklch(97% 4% 140 / 95%);
    --tooltip-text-light: oklch(30% 4% 140);
    --border-color: oklch(75% 8% 140 / 50%);
  }
}

/* General body styles */
body {
  font: 100%/1.5 system-ui;
  max-width: 100ch;
  margin-inline: max(1em, (100% - 100ch) / 2);
  padding-inline: 1em;
  background: inherit;
  color: inherit;
}

input,
textarea,
button {
  font: inherit;
}

/* Style images */
img {
  width: 100%;
  max-width: 300px;
  height: auto;
  display: block;
  margin: 20px auto;
  border-radius: 8px;
}

/* Navigation bar container */
nav {
  display: flex;
  text-decoration: none;
  gap: 1em;
  color: inherit;
  text-align: center;
  justify-content: center;
  padding: 0.5em;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2em;
}

/* Nav links */
nav a {
  flex: 1;
  text-align: center;
  padding: 0.5em;
  text-decoration: none;
  color: inherit;
  border-bottom: 0.2em solid transparent;
  transition: border-color 0.2s, background-color 0.2s;
}

/* Current page link */
nav a.current {
  border-bottom: 0.4em solid var(--border-color);
  padding-bottom: 0.3em;
}

/* Hover effects */
nav a:hover {
  border-bottom: 0.4em solid var(--color-accent);
  color: var(--color-accent);
  padding-bottom: 0.3em;
  background-color: color-mix(in srgb, currentColor 10%, transparent);
}

/* Dark mode fix for hover
@media (prefers-color-scheme: dark) {
  nav a:hover {
    background-color: color-mix(in oklch, var(--color-accent), canvas 85%);
  }
} */

@media (prefers-color-scheme: dark) {
  nav a:hover {
    /* Mixing the background color with the accent color in dark mode */
    background-color: color-mix(in oklch, var(--color-accent), canvas 85%);
    color: var(--color-accent); /* Ensure text remains legible */
  }
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
  nav {
    flex-direction: column;
    align-items: stretch; /* Make nav items take full width */
  }

  nav a {
    text-align: center; /* Ensure text is centered */
    border-bottom: 1px solid var(--border-color); /* Add a light separator */
    padding: 0.8em 0.5em; /* Adjust padding for vertical layout */
  }

  nav a.current,
  nav a:hover {
    border-bottom-width: 0.4em; /* Keep consistent border for current/hover */
    padding-bottom: calc(0.8em - 0.4em + 0.3em); /* Adjust padding to maintain height */
  }

  .typed-text {
    font-size: 40px; /* Reduce font size for smaller screens */
  }

  .projects {
    grid-template-columns: 1fr; /* Single column for projects */
  }

  #profile-stats dl {
    grid-template-columns: repeat(2, 1fr); /* Two columns for stats */
  }

  .container {
    flex-direction: column; /* Stack elements in container */
    gap: 1rem;
  }

  .stats {
    grid-template-columns: 1fr; /* Single column for stats sections */
  }

  #files {
    grid-template-columns: 1fr; /* Single column for files section */
  }

  #files > div {
    grid-template-columns: 1fr; /* Ensure subgrid also stacks */
  }

  #files dt,
  #files dd {
    grid-column: 1; /* Ensure dt and dd are in the single column */
  }

  .lines-container {
    padding-top: 0.3em; /* Adjust padding for tighter mobile layout */
  }

  #scrolly-1 {
    flex-direction: column; /* Stack scrollytelling sections */
  }

  #scatter-plot {
    position: relative; /* Change from sticky for stacked layout */
    height: auto; /* Adjust height for stacked layout */
    min-height: 300px; /* Ensure it's not too small */
    width: 100%; /* Take full width in column flow */
  }
}

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

/* The .typing-container rule below is removed, div will be block by default */
/*
.typing-container {
  display: inline-block; 
}
*/

.typed-text {
  font-family: inherit; 
  font-size: 60px; /* Increase this for bigger text (e.g., 1.25em or 20px) */
  display: inline;
  overflow: hidden; 
  white-space: nowrap; 
  border-right: 0.15em solid rgb(11, 76, 11);
  letter-spacing: 0.03em; /* Reduce from 0.1em to something like 0.03em */
  animation:
    typing 2s steps(11, end),
    blink-caret 0.75s step-end infinite;
  vertical-align: bottom; 
}


@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: rgb(11, 76, 11); }
}

/* Contact form styles */
form {
  max-width: 600px;
  margin: 0 auto;
}

label {
  display: block;
  font-weight: bold;
  margin-block: 0.5em 0.25em;
}

input,
textarea,
button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.5em;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-bottom: 1em;
}

button {
  background-color: var(--color-accent);
  color: white;
  font-weight: bold;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s;
}

/* button:hover {
  background-color: oklch(from var(--color-accent) 60% 40% h);
} */
button:hover {
  background-color: color-mix(in oklch, var(--color-accent), canvas 85%); /* Apply the same background mix */
}

button:focus {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Projects grid */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15em, 1fr));
  gap: 1em;
  padding-block: 2em;
  grid-auto-rows: subgrid;
}

.projects article {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;
  background: oklch(85% 10% 140);
  padding: 1em;
  border-radius: 8px;
  box-shadow: 0 2px 5px oklch(0% 0% 0% / 0.05);
  transition: transform 0.2s ease-in-out;
}

.projects article:hover {
  transform: translateY(-5px);
}

.projects h2 {
  font-size: 1.25em;
  margin: 0;
}

.projects img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  margin-bottom: 1em;
}

.projects p {
  font-size: 0.95em;
  line-height: 1.4;
}

/* Resume-specific styles */
/* body.resume {
  padding-block: 2em;
}
 */
section {
  margin-bottom: 2.5em;
  padding-bottom: 1.5em;
  border-bottom: 1px solid var(--border-color);
}

section > header h2 {
  font-size: 1.75em;
  color: inherit;
  margin-bottom: 0.5em;
}

article {
  margin-bottom: 1.5em;
}

article h3 {
  font-size: 1.25em;
  margin-bottom: 0.3em;
  color: inherit;
}

article p {
  margin: 0.2em 0 0.3em 0;
  font-weight: 500;
}

article time {
  display: inline-block;
  font-size: 0.9em;
  color: oklch(70% 6% 140);
  margin-top: 0.3em;
}

/* Skills list */
ul {
  list-style-type: "✦ ";
  padding-left: 1em;
}

ul li {
  margin-bottom: 0.4em;
  font-weight: 500;
}

section:last-of-type {
  background: oklch(from var(--color-accent) 97% 0.03 h);
  padding: 1em;
  border-radius: 0.5em;
}

/* ---------------------------------------
   Tooltip Styling & Interaction
---------------------------------------- */
.tooltip {
  position: fixed;
  top: 1em;
  left: 1em;
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.9); /* translucent white */
  color: var(--tooltip-text-light);
  padding: 1em;
  border-radius: 0.75em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* soft shadow */
  backdrop-filter: blur(8px); /* frosted glass effect */
  border: 1px solid var(--border-color);
  font-size: 0.9em;
  line-height: 1.4;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tooltip[hidden] {
  opacity: 0;
  visibility: hidden;
}

@media (prefers-color-scheme: dark) {
  .tooltip {
    background-color: rgba(32, 32, 32, 0.85);
    color: var(--tooltip-text-dark);
    border-color: rgba(255, 255, 255, 0.1);
  }
}

/* ---------------------------------------
   Dot Hover and Selected States
---------------------------------------- */
circle {
  transition: 200ms;
  transform-origin: center;
  transform-box: fill-box;
}

circle:hover {
  transform: scale(1.5);
}

circle.selected {
  fill: #ff6b6b;
  stroke: black;
  stroke-width: 2px;
}

/* ---------------------------------------
   Brushing Selection Rectangle
---------------------------------------- */
@keyframes marching-ants {
  to {
    stroke-dashoffset: -8;
  }
}

.selection {
  fill-opacity: 0.1;
  stroke: black;
  stroke-opacity: 0.7;
  stroke-dasharray: 5 3;
  animation: marching-ants 2s linear infinite;
}

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

html {
  transition: background-color 0.4s, color 0.4s, border-color 0.4s;
}

/* Falling Leaves 🍃 */
.leaves {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* So leaves don't block clicks */
  overflow: hidden;
  z-index: 10; /* Lower than nav, higher than background */
}

.leaf {
  position: absolute;
  top: -10vh;
  font-size: 2rem;
  animation: fall 12s linear infinite;
  opacity: 0.8;
}


#profile-stats dl {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

#profile-stats dt {
  font-weight: bold;
  grid-row: 1;
}

#profile-stats dd {
  margin: 0;
  grid-row: 2;
}

.project-year {
  font-family: Baskerville, serif;
  color: gray;
  font-size: 0.9em;
  font-variant-numeric: oldstyle-nums;
}

#projects-pie-plot {
  max-width: 20em;
  margin-block: 2em;
  overflow: visible;
}

.container {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9em, 1fr));
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #ccc;
  flex: 1;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.swatch {
  width: 1em;
  height: 1em;
  background-color: var(--color);
  display: inline-block;
  border-radius: 0.25em;
}

/* Highlight hovered wedges */
svg:has(path:hover) path:not(:hover) {
  opacity: 0.5;
}

path {
  transition: 300ms;
  cursor: pointer;
}

/* Selected slice + legend style */
.selected {
  --color: oklch(60% 45% 0) !important;
}

.selected:is(path) {
  fill: var(--color);
}

svg:has(path:hover) path:not(:hover) {
  opacity: 0.5;
}

path {
  transition: 300ms;
  cursor: pointer;
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9em, 1fr));
  gap: 1em;
  border: 1px solid gray;
  padding: 1em;
  margin-block: 2em;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.swatch {
  display: inline-block;
  width: 1em;
  height: 1em;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background-color: var(--color);
}

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

.selected:is(path) {
  fill: var(--color);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 2em;
}

.stats dt {
  font-weight: bold;
  color: var(--color-accent);
  font-size: 1.1em;
}

.stats dd {
  margin: 0 0 1em 0;
  font-size: 1.25em;
  font-weight: 600;
}

.gridlines line {
  stroke: oklch(80% 0.05 240);
  stroke-opacity: 0.3;
  shape-rendering: crispEdges;
}

.gridlines path {
  display: none;
}

/* Tooltip layout */
dl.info {
  display: grid;
  grid-template-columns: max-content auto;
  gap: 0.5em 1em;
  margin: 0;
  padding: 1em;
  background: white;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 0.5em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

dl.info dt {
  font-weight: bold;
  opacity: 0.7;
}

dl.info dd {
  margin: 0;
}

/* Hover scaling effect for dots */
circle {
  transition: 200ms;
  transform-origin: center;
  transform-box: fill-box;
}

circle:hover {
  transform: scale(1.5);
}

/* Project card clickable link */
.project-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.project-link:hover {
  text-decoration: none;
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

/* ANIMATION! */
#time-slider #commit-progress {
  flex: 1; 
  align-items: baseline;
}

#commit-time {
  margin-left: auto;
  font-weight: normal;
  display: inline;
  color: black;
}

#time-slider label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* biggest file */

#files {
  display: grid;
  grid-template-columns: 1fr 4fr;

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

  dt {
    grid-column: 1;
  }

  dd {
    grid-column: 2;
  }
}

#files dt small {
  display: block;        /* puts it on its own line under the filename */
  font-size: 0.8em;      /* smaller text */
  opacity: 0.6;          /* less prominent */
  margin-top: 0.2em;     /* a bit of breathing room */
}

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

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

/* SCROLLY TELLING */
#scrolly-1 {
  position: relative;
  display: flex;
  gap: 1rem;

  > * {
    flex: 1;
  }
}

#scatter-story {
  position: relative;
}

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

/* Further adjustments for very small screens */
@media (max-width: 480px) {
  .typed-text {
    font-size: 30px; /* Even smaller font for very small screens */
    letter-spacing: 0.02em;
    border-right-width: 0.1em;
  }

  #profile-stats dl {
    grid-template-columns: 1fr; /* Single column for stats on very small screens */
  }

  body {
    margin-inline: 1em; /* Reduce side margins */
    padding-inline: 0.5em;
    font-size: 95%; /* Slightly reduce base font size */
  }

  h1 {
    font-size: 1.8em; /* Adjust h1 size */
  }

  nav a {
    padding: 0.6em 0.5em;
  }

  nav a.current,
  nav a:hover {
    padding-bottom: calc(0.6em - 0.4em + 0.3em);
  }

  .legend {
    padding: 0.5em;
    gap: 0.5em;
  }
}



