:root {
  --color-accent: oklch(65% 50% 0);
  /*--article-bg: var(--article-bg-light);  Default to light mode */
  --article-bg-light: #e2d2d4; /* Light pink */
  --article-bg-dark: #5e303a; /* Dark pinkish-gray */
}

@media (prefers-color-scheme: dark) {
  :root {
    --article-bg: var(--article-bg-dark); /* Dark mode */
  }
}

@media (prefers-color-scheme: light) {
  :root {
    --article-bg: var(--article-bg-light); /* Light mode */
  }
}

/* Apply the accent color to all elements that use it */
html {
  /*accent-color: var(--color-accent); */
  color-scheme: light dark; /* Automatic dark mode */
}

/* Theme switcher styling */
.color-scheme {
  position: fixed; /* Fixed positioning ensures it's relative to the viewport */
  top: 0.5rem; /* Distance from the top */
  right: 1rem; /* Distance from the right */
  z-index: 1000; /* Ensure it stays above the navigation */
  font-size: 80%;
  font-family: inherit;
  background-color: transparent; /* Default background */
  border: none; 
  border-radius: 0.25em; /* Rounded corners */
  display: inline-block; /* Ensure it takes the proper size */
}

.color-scheme select {
  background-color: white; /* Match dropdown background */
  color: black; /* Ensure text color matches theme */
  border-radius: 0.25em; /* Match rounded corners */
  border: 0.8px solid #ccc; /* Subtle border for better definition */
}

body {
    /* Set line height to 1.5 times the font size
         and use the OS’s UI font as the website font
       */
    font: 100%/1.5 system-ui;

    /* Set a max-width for the body */
    max-width: 140ch;

    /* Center content */
    margin-inline: auto;

    /* Add padding for spacing near the edges*/
    padding: 2em;
  }

/* Navigation bar styling ----------------------------------------*/

  nav {
    position: relative;
    display: flex; /* Make the parent a flex container */
    justify-content: space-around; /* Distribute links evenly */
    align-items: center; /* Align items vertically */
    border-bottom: 1px solid var(--color-accent); /* color of bottom border */
    --border-color: oklch(50% 10% 200 / 40%);
    border-bottom-color: var(--border-color);
    z-index: 1;
}

nav a {
    flex: 1; /* Ensure all <a> elements take up equal space */
    text-decoration: none; /* remove underline for links */
    color: inherit; /* make links use the same text color as their parent element*/
    text-align: center; /* Center the text inside each link */
    padding: 0.5em; /* Add padding for better spacing */
    transition: all 0.3s ease; /* Smooth hover effect */    
}

/* Style for the current page link */
nav a.current {
  border-bottom: 0.4em solid oklch(85% 3% 200); /* Thicker bottom border */
  padding-bottom: 0.1em; /* Reduce padding to counter height increase */
}

/* Style for hovered navigation links */
nav a:hover {
  border-bottom: 0.4em solid var(--color-accent); /* Accent-colored border */
  background-color: color-mix(in oklch, var(--color-accent), canvas 85%); /* Light background with the same hue */
  padding-bottom: 0.1em; /* Reduce padding to counter border height */
}

/* Form styling --------------------------------------------------*/

form {
  display: grid; /* Enable grid layout for the form */
  grid-template-columns: auto 1fr; /* Two columns: labels and inputs */
  gap: 1em; /* Add spacing between rows and columns */
  max-width: 80ch; /* Limit the form width for readability */
  margin: 0 auto; /* Center the form horizontally */
}

label {
  display: contents; /* Make labels behave as inline containers, letting children align to the grid */
}

label span {
  grid-column: 1; /* Place the label text in the first column */
  align-self: center; /* Vertically center-align label text */
  text-align: right; /* Align text to the right for readability */
  padding-right: 1em; /* Add spacing between label and input */
}

input, textarea {
  grid-column: 2; /* Place the input field in the second column */
  width: 100%; /* Make inputs stretch to fit the column */
  padding: 0.5em; /* Add padding for usability */
  border: 1px solid oklch(80% 3% 200); /* Subtle border color */
  border-radius: 0.25em; /* Slightly rounded corners */
  box-sizing: border-box; /* Include padding and border in the width */
}

button {
  grid-column: 1 / -1; /* Make the button span across all columns */
  justify-self: center; /* Center the button horizontally */
  padding: 0.5em 1em; /* Add padding for better usability */
  border: none; /* Remove default border */
  background-color: var(--color-accent, oklch(65% 50% 0)); /* Use accent color */
  color: white; /* Make button text white */
  border-radius: 0.25em; /* Slightly rounded corners */
  cursor: pointer; /* Pointer cursor on hover */
  transition: background-color 0.3s ease; /* Smooth hover effect */
}

button:hover {
  background-color: oklch(60% 45% 0); /* Slightly darker hover background */
}

/* Article and project styling -----------------------------------*/

.projects {
  display: grid; /* Make .projects a grid container */
  grid-template-columns: repeat(auto-fill, minmax(15em, 1fr)); /* Flexible column layout */
  gap: 1.5em; /* Add spacing between grid items */
  padding: 1em; /* Add padding around the grid for spacing */
}

.projects article {
  display: grid; /* Make each <article> a grid container */
  grid-template-rows: auto auto 1fr; /* Explicitly define rows: heading, image, content */
  gap: 1em; /* Add spacing between elements within each article */
  padding: 1em; /* Add padding inside articles */
  border: 1px solid #ddd; /* Subtle border for distinction */
  border-radius: 0.5em; /* Slightly rounded corners */
  background-color: var(--article-bg); /* Adapt background color */
}

.projects h2 {
  grid-row: 1; /* Place the heading in the first row */
  margin: 0; /* Remove default margin to avoid excessive spacing */
  font-size: 1.2em; /* Adjust heading size */
  text-align: center; /* Center-align headings */
}

.projects img {
  grid-row: 2; /* Place the image in the second row */
  width: 100%; /* Make images responsive */
  max-width: 10em; /* Set a consistent max width for images */
  height: auto; /* Maintain aspect ratio */
  justify-self: center; /* Center-align images horizontally */
}

.projects p {
  grid-row: 3; /* Place the paragraph in the third row */
  font-size: 0.9em; /* Adjust paragraph text size */
  line-height: 1.4; /* Improve readability */
  text-align: justify; /* Optional: Justify text for cleaner alignment */
}

article p {
  margin: 0; /* Remove extra margin between paragraphs */
}

.project-year {
  display: block; /* Force it to take up its own line */
  margin-top: 0.5em; /* Add space above the year */
  font-style: italic; /* Italicize the year */
  color: #8d8d8d; /* muted text color */
}

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

  overflow: visible;
}

/* Projects Legend styling ------------------------------------------*/
.legend li {
  display: flex;
  align-items: center; /* Center-align text and swatch */
  gap: 0.5rem; /* Space between swatch and text */
  cursor: pointer;
}

.legend .swatch {
  width: 1em; /* Make it a square */
  height: 1em;
  aspect-ratio: 1 / 1;
  background-color: var(--color); /* Use custom property for color */
  border-radius: 0.25em; /* Slightly rounded corners */
  cursor: pointer;
}

.container {
  display: flex; /* Use flexbox for alignment */
  align-items: center; /* Vertically center the items */
  justify-content: center; /* Center items horizontally (if needed) */
  gap: 2rem; /* Space between the pie chart and the legend */
  margin-top: 1rem; /* Space above the container */
}

.chart-container {
  display: flex; /* Ensures proper layout inside this container */
  flex-direction: column; /* Stacks SVG and legend */
  gap: 1rem; /* Adds space between pie chart and legend */
}

svg {
  flex: 0 0 auto; /* Prevent SVG from stretching */
  max-width: 15em; /* Limit size of pie chart */
  aspect-ratio: 1 / 1; /* Ensure it stays a circle */
}

.legend {
  flex-grow: 1; /* Ensure it takes up remaining space */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9em, 1fr)); /* Auto-adjust columns */
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #ddd;
  background-color: transparent;
  border-radius: 0.5rem;
}

/* General styles for all headings ----------------------------*/
h1, h2, h3, h4, h5, h6 {
  line-height: 1.1; /* Tighter leading for headings */
  text-wrap: balance; /* Prevent uneven line breaks */
  margin: 0.5em 0; /* Add consistent spacing around headings */
}

/* Specific styles for individual heading levels */
h1 {
  font-size: 200%; /* Make <h1> significantly larger for contrast */
}

h2 {
  font-size: 170%; /* Distinguish <h2> from <h1> and body text */
}

h3 {
  font-size: 150%; /* Slightly smaller than <h2>, for subheadings */
}

h4, h5, h6 {
  font-size: 125%; /* Use progressively smaller sizes for lower headings */
}

/* Github Widget Styles ----------------------- */

#profile-stats dl {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* Four equal-sized columns */
  gap: 1rem; /* Spacing between grid items */
}

#profile-stats dt {
  font-weight: bold;
  text-align: center;
  white-space: nowrap; /* Prevent text from breaking into new lines */
  grid-row: 1; /* Place all <dt> elements in the first row */
}

#profile-stats dd {
  text-align: center;
  grid-row: 2; /* Place all <dd> elements in the second row */
  margin: 0; /* Remove default margins */
}

#github-avatar {
  display: block;
  margin: 0 auto 1rem; /* Center the image and add spacing below */
  width: 70px; /* Set the desired size of the avatar */
  height: 70px; /* Maintain a square shape */
  border-radius: 50%; /* Make it circular */
  border: 1px solid var(--color-accent); /* Optional: Add a border */
}

/* Projects Pie Chart Styles ---------------------------------------*/

/* Highlight hovered wedges */
#projects-pie-plot:has(path:hover) path:not(:hover) {
  opacity: 0.5;
}

#projects-pie-plot path {
  transition: 300ms;
  cursor: pointer; /* Indicate that wedges are clickable */
}

/* Highlight selected wedge */
.selected {
  --color: oklch(60% 45% 0) !important; /* Custom color for selected */
}

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

.selected:is(li) {
  font-weight: bold;
}

/* Summary Statistics  in META section ------------------------------*/

.stats {
  display: grid;
  grid-template-columns: repeat(7, 1fr); /* 7 equal-sized columns */
  gap: 1rem; /* Spacing between grid items */
}

.stats dt {
  font-weight: bold;
  text-align: center;
  white-space: nowrap; /* Prevent text from breaking into new lines */
  grid-row: 1; /* Place all <dt> elements in the first row */
  font-size: 10px;
  color: gray;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stats dd {
  text-align: center;
  grid-row: 2; /* Place all <dd> elements in the second row */
  margin: 0; /* Remove default margins */
  font-weight: bold;
  margin: 0;
}

/*Meta scatter plot chart styles------------------------------------*/

#chart svg {
  width: 100%;
  height: 600px;  /* Ensure sufficient height */
  max-width: 1000px;
}

#chart {
  width: 100%;
  max-width: 1000px;
  display: flex;
  justify-content: center;
}

.gridlines line {
  stroke-opacity: 0.3;  /* Makes them less prominent */
  stroke-width: .5;  /* Thinner lines */
  stroke-dasharray: 4 4; /* Creates dashed lines instead of solid */
}

/* Mouseover tooltip styles --------------------------------------*/

.tooltip {
  position: fixed;
  top: 1em;
  left: 1em;
  padding: 0.75em;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.15);
  border-radius: 5px;
  backdrop-filter: blur(5px);
  transition: opacity 300ms, visibility 300ms;
  font-size: 0.9em;
  max-width: 200px;
}

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

dl.info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
}

dl.info dt {
  font-weight: bold;
  color: #7e7e7e;
}

dl.info dd {
  margin: 0;
  font-weight: normal;
}

circle {
  transition: transform 200ms ease-in-out;
  transform-origin: center;
  transform-box: fill-box;
}

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

/* Brush styles---------------------------------------------*/

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

circle.selected {
  fill: #ffacba;
}

/* --------------------------------------*/