/* =========================================
   BASE STYLES
   ========================================= */

/* ---- Body ---- */
body {
  /* Font: system default, comfortable line height */
  font: 100%/1.5 system-ui;
  max-width: 100ch;
  padding: 20px;
  margin: 0 auto;
}

/* ---- Images ---- */
img {
  max-width: 100%;
}

/* =========================================
   THEME / ROOT VARIABLES
   ========================================= */

/* ---- Accent Colors ---- */
:root { --color-accent: oklch(64% 0.17 45); }   /* main accent color (light) */
html  { accent-color: var(--color-accent); }

/* ---- Fallbacks ---- */
:root { --orange: oklch(64% 0.17 45); }
@supports not (color: oklch(0% 0 0)) { 
  :root { --orange: #de6118; } /* fallback for older browsers */
}

/* ---- Light / Dark Mode ---- */
html {
  color-scheme: light dark;
  background: canvas;
  color: canvastext;
}

/* =========================================
   NAVIGATION (shared)
   ========================================= */

nav {
  display: flex;
  gap: 1rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  --border-color: oklch(50% 10% 200 / 40%);
  border-bottom: 1px solid var(--border-color);
}

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

/* ---- Active Tab ---- */
nav a.current {
  font-weight: 700;
  border-bottom: 0.4em solid var(--orange);
  padding-bottom: calc(0.5em - 0.4em);
}

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

/* ---- Form Elements (inherit font) ---- */
input, textarea, button { 
  font: inherit; 
}

/* =========================================
   INTRO SECTION HOME PAGE (TEXT + IMAGE)
   ========================================= */

.intro-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.intro-text {
  flex: 1 1 60%;
  max-width: 600px;
}

/* =========================================
   CONTACT FORM
   ========================================= */

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

form label {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
}

form label > span {
  grid-column: 1;
  align-self: center;
}

form input,
form textarea {
  grid-column: 2;
  width: 100%;
  box-sizing: border-box;
}

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

/* =========================================
   PROJECTS SECTION
   ========================================= */

/* ---- Project Grid ---- */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15em, 1fr));
  gap: 1em;
  margin-block: 1rem;
  grid-auto-rows: min-content; /* ensures consistent row height */
}

/* ---- Project Card ---- */
.projects article {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;  /* h2, img, p */
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 1px 0 var(--ring);
  transition: box-shadow 150ms ease, transform 150ms ease, border-color 150ms ease;
}

.projects article:hover {
  border-color: oklch(70% 0.12 45);
  box-shadow: 0 6px 18px var(--ring);
  transform: translateY(-2px);
}

/* ---- Titles & Images ---- */
.projects h2 { margin: 0; }
.projects img { width: 100%; height: auto; display: block; }

/* ---- Description + Year Wrapper ---- */
.project-info {
  margin-top: 0.5em;
}

.project-info p {
  margin: 0.25em 0;
}

/* ---- Year Styling ---- */
.project-year {
  font-size: 0.9rem;
  opacity: 0.8;
  font-style: italic;
}

.no-results {
  grid-column: 1 / -1;   /* spans full row */
  text-align: center;
  font-size: 1.1rem;
  padding: 2rem 0;
  opacity: 0.7;
}


/* =========================================
   PIE CHART + LEGEND
   ========================================= */

/* ---- Chart + Legend Wrapper ---- */
.chart-container {
  display: flex;
  align-items: center;
  gap: 2rem;               /* spacing between chart + legend */
  margin-block: 3rem;      /* consistent vertical spacing */
  flex-wrap: wrap;         /* wraps on small screens */
}

/* ---- Pie Chart SVG ---- */
#pieChart {
  width: 250px;
  height: 250px;
  max-width: 20em;         /* responsive cap */
  aspect-ratio: 1 / 1;     /* keeps it a square */
  overflow: visible;
  margin: 0;               /* container handles spacing */
  display: block;
}

/* ---- Legend Grid ---- */
.legend {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9em, 1fr));
  gap: 1.5rem;
  padding: 1rem;
  margin-block: 2rem;
  border: 2px solid #ccc;   /* default border for light mode */
  border-radius: 8px;
  background: #fff;         /* light mode default */
  color: #000;
}

/* ---- Legend Item ---- */
.legend li {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

/* ---- Legend Swatch ---- */
.legend li .swatch {
  width: 1em;
  height: 1em;
  background: var(--color);
  border-radius: 50%;
  display: inline-flex;
}

/* ---- Dark Mode ---- */
@media (prefers-color-scheme: dark) {
  .legend {
    background: #1e1e1e;   /* match site dark tone */
    color: #fff;
    border-color: #444;    /* subtle dark border */
  }
}

/* =========================================
   HEADINGS
   ========================================= */

h1 { 
  font-size: 400%; 
  line-height: 1.1; 
  text-wrap: balance; 
}

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

/* =========================================
   RESUME SECTION
   ========================================= */

/* ---- Page Layout ---- */
.cv {
  max-width: 75ch;
  margin: 2rem auto;
  display: grid;
  gap: 1.25rem;
}

/* ---- Section Dividers ---- */
.cv section {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--orange);
}

/* ---- Header ---- */
.cv-header h1 { 
  margin: 0 0 .25rem; 
  font-size: 280%; 
  line-height: 1.1; 
}
.cv-header p { margin: 0; }

/* ---- Rows with Right-Aligned Info ---- */
.cv .row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.2rem 1rem;
}

.cv .row .right { 
  text-align: right; 
  white-space: nowrap; 
}

.degree-line { 
  margin: 0; 
  font-style: italic; 
}

.degree-detail {
  margin: 0;
}

.cv .row .place,
.cv .row .date { 
  margin: 0; 
  color: black; 
  font-weight: 500; 
}

/* ---- Resume Headings ---- */
.cv h2 { 
  margin: .5rem 0; 
  line-height: 1.1; 
  text-wrap: balance; 
  color: var(--color-accent); 
}
.cv h3 { 
  margin: 0; 
  line-height: 1.15; 
}
.cv .muted { 
  opacity: .7; 
  font-weight: 500; 
}

/* ---- Lists ---- */
.cv .bullets { margin: .35rem 0 0; }
.cv .bullets li { margin: .2rem 0; }

/* ---- Projects: tighter spacing + bullets ---- */
.cv section[aria-labelledby="proj"] article > p {
  margin: 0.15rem 0 0.2rem; /* small gap under title and before bullets */
}

.cv section[aria-labelledby="proj"] .bullets {
  margin: 0.35rem 0 0.4rem;
}

.cv section[aria-labelledby="proj"] .bullets li {
  margin: 0.15rem 0;
}

/* small separation between individual projects */
.cv section[aria-labelledby="proj"] article + article {
  margin-top: 0.5rem;
}

/* ---- Inline Degrees ---- */
.inline-degrees { margin: 0; }
.inline-degrees em { font-style: italic; }

/* ---- Resume Links ---- */
.cv .links a { 
  text-decoration: none; 
  color: inherit; 
  border-bottom: 2px solid var(--color-accent); 
}
.cv .links a:hover { 
  border-bottom-width: .4em; 
}

/* ---- Project Blocks ---- */
.cv .project { margin-bottom: 1.25rem; }

.proj-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-bottom: 0.3rem;
}

.proj-head .title { 
  flex: 1 1 20rem; 
}

.proj-head .links {
  margin-left: auto;
  white-space: nowrap;
  text-align: right;
  flex-basis: auto;
}

.project-links {
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.project-links a {
  color: #ff914d; /* pick your accent */
  text-decoration: none;
  font-weight: 500;
}

.project-links a:hover {
  text-decoration: underline;
}


/* ---- Responsive (narrow widths) ---- */
@media (max-width: 700px) {
  .proj-head .links { flex-basis: 100%; }
}

/* ---- Titles + Links ---- */
.proj-head h3 { margin: 0; font-weight: 600; }
.proj-head .links { margin: 0; font-size: 0.95em; white-space: nowrap; }
.proj-head .links a { text-decoration: none; border-bottom: 2px solid var(--color-accent); }
.proj-head .links a:hover { border-bottom-width: 0.4em; }

/* ---- List Spacing ---- */
.cv .project ul { margin-top: 0.3rem; margin-bottom: 0.8rem; }
.cv .project ul li { margin: 0.25rem 0; }

/* ---- Section Spacing ---- */
.cv [aria-labelledby="edu"] article + article h3 { margin-top: 0.9rem; }
.cv .project + .project { margin-top: 1.1rem; }

/* ---- Resume Download Link ---- */
.cv .download a {
  display: inline-block;
  text-decoration: none;
  color: inherit;
  border-bottom: 2px solid var(--color-accent);
}
.cv .download a:hover { border-bottom-width: .4em; }

/* =========================================
   DARK MODE
   ========================================= */

@media (prefers-color-scheme: dark) {
  html { color-scheme: dark; }
  body { background: canvas; color: canvastext; }

  /* ensure secondary text remains readable */
  .right,
  .date,
  .place { color: canvastext !important; }
}

/* =========================================
   GITHUB STATS
   ========================================= */

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

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

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

/* ---- Hover Interaction ---- */
#profile-stats dd:hover {
  transform: scale(1.05);
  transition: transform 0.2s ease;
  color: #de6118;
}

/* ---- Profile Image ---- */
.profile-pic {
  width: 300px;
  height: auto;
  border-radius: 12px;
  display: block;
  margin: 20px auto;
}

#pieChart path { cursor: pointer; transition: 300ms; }
#pieChart:has(path:hover) path:not(:hover) { opacity: .5; }
#pieChart path.selected {fill: oklch(32% 0 0) !important;}

/* highlight legend item */
.legend li.selected {font-weight: 600; opacity: 1;}

.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  font-size: 1rem;
  margin: 1rem 0;
}

.stats dt {
  font-weight: bold;
  text-align: right;
  opacity: 0.7;
}

.stats dd {
  margin: 0;
}

.summary-box {
  display: flex;
  justify-content: space-between;
  padding: 20px;
  border: 2px solid var(--card-border);
  border-radius: 8px;
  background: var(--card);
  margin-top: 20px;
  box-shadow: 0 1px 0 var(--ring);
}

.summary-box .stat {
  text-align: center;
  flex: 1;
}

.summary-box .value {
  font-size: 2rem;
  font-weight: bold;
}

.summary-box .label {
  font-size: 0.9rem;
  letter-spacing: 1px;
  color: #555;
  margin-top: 4px;
  text-transform: uppercase;
}

:root {
  --card: white;
  --card-border: #ccc;
  --ring: rgba(0,0,0,0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --card: #1a1d20;
    --card-border: #333;
    --ring: rgba(255,255,255,0.03);
  }
}

/* Make gridlines faint and clean */
.grid line {
  stroke: #888;
  opacity: 0.50;
  shape-rendering: crispEdges;
}

.grid path {
  stroke: none;
}

/* Dots on hover */
.dots circle:hover {
  stroke: white;
  stroke-width: 1.5;
  transform: scale(1.5);
}

/* Shared info list layout */
dl.info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
  transition-duration: 500ms;
  transition-property: opacity, visibility;
}

dl.info dt {
  opacity: 0.6;
  font-size: 0.75rem;
}

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

/* Tooltip styling */
.tooltip {
  position: fixed;
  background: rgba(30, 30, 30, 0.85);
  color: white;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
  pointer-events: none; /* so it doesn’t block mouse */
}

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

/* Dot hover animation */
circle {
  transition: 200ms;
  transform-origin: center;
  transform-box: fill-box;
}

@keyframes marching-ants {
  to {
    stroke-dashoffset: -8; /* 5 + 3 */
  }
}

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

circle.selected {
  fill: #ff6b6b;
}

/* Tooltip hidden state (matches #commit-tooltip id) */
#commit-tooltip[hidden] {
  opacity: 0;
  visibility: hidden;
}

.language-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-top: 2rem;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.4rem;
}

.language-stats .lang-block {
  display: grid;
  gap: 0.5rem;
}

.language-stats dt {
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0;
}

.language-stats dd {
  margin: 0;
  line-height: 1.4;
}

/* =========================================
   META TIME FILTER SLIDER
   ========================================= */
.time-filter-wrapper {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

#meta-scroll-anchor {
  position: sticky;
  top: 0;
  z-index: 5;
  background: canvas;
  padding-block: 0.5rem 1rem;
}

#time-filter {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  align-items: center;
  width: auto;
}

#time-filter span {
  white-space: nowrap;
  margin-right: 0.5rem;
  font-weight: 800;
}

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

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

  dt {
    grid-column: 1;
  }
}

#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;
}

.loc {
  display: flex;
  width: 0.5em;
  aspect-ratio: 1;
  background: var(--color, #de6118);  /* <- changed */
  border-radius: 50%;
}

#files code small {
  display: block;
  font-size: 0.8em;
  opacity: 0.7;
}

#scrolly-1 {
  position: relative;
  display: flex;
  gap: 1rem;
}

#scatter-story {
  position: relative;
  flex: 0 0 20%;
  max-width: 20ch;
  padding-right: 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

#scatter-story .step {
  padding-bottom: 8vh;
  opacity: 0.5;
  transition: opacity 200ms;
}

#scatter-story .step.is-active {
  opacity: 1;
}

#scatter-story .step.is-hover {
  opacity: 1;
  text-decoration: underline;
}

#scatter-plot {
  position: sticky;
  top: 20rem;
  left: 0;
  bottom: auto;
  height: 65vh;
  flex: 1 1 0;
}

#scatter-plot #chart svg {
  width: 100%;
  height: 100%;
}

.chart-caption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.7;
  text-align: right;
}

.files-caption {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}
