/* Each colour is defined once via light-dark(); `color-scheme` decides which
   value resolves. Default follows the OS; the nav toggle forces one by setting
   data-theme on <html> (persisted in localStorage). */
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #0f1115);
  --fg: light-dark(#1a1a1a, #e6e6e6);
  --muted: light-dark(#6a6a6a, #9aa0a6);
  --rule: light-dark(#e5e5e5, #2a2d33);
  --accent: light-dark(#ea580c, #fb923c);
  --card: light-dark(#ffffff, #161a21);
  --maxw: min(92%, 1600px);
  --radius: 6px;
  /* proficiency scale — light→deep (light mode), dim→bright (dark mode) */
  --lvl-1: light-dark(#fdba74, #7c4a1e);
  --lvl-2: light-dark(#fb923c, #a8632a);
  --lvl-3: light-dark(#f97316, #d97b30);
  --lvl-4: light-dark(#ea580c, #fb923c);
  --lvl-5: light-dark(#c2410c, #fdba74);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header / nav */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-nav {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.site-nav .brand {
  font-weight: 600;
  color: var(--fg);
}
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-nav ul a {
  color: var(--muted);
  font-size: 0.95rem;
}
.site-nav ul a:hover { color: var(--fg); text-decoration: none; }

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--rule));
}
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle .icon { display: none; }
/* light (or unset on a light OS): offer the moon. dark: offer the sun. */
.theme-toggle .moon { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .moon { display: none; }
  :root:not([data-theme]) .theme-toggle .sun { display: block; }
}

/* Intro */
.intro { padding: 3rem 0 2.5rem; }
.intro-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.75rem 2rem;
  align-items: start;
}
.avatar {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  justify-self: center;
  align-self: center;
}
.intro-text { min-width: 0; }
@media (max-width: 640px) {
  .intro-inner { grid-template-columns: 1fr; }
}
.intro-text h1 {
  font-size: 1.9rem;
  margin: 0 0 0.25rem;
  line-height: 1.25;
}
.intro-text .name { color: var(--accent); }
.intro-text .role {
  color: var(--muted);
  margin: 0 0 1rem;
}
.bio { text-align: justify; }
.bio p { margin: 0 0 0.85rem; }
.bio p:last-child { margin-bottom: 0; }

/* Social links + badges row */
.intro-meta {
  margin-top: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.4rem;
}

/* Social links */
.social {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
  background: var(--card);
  transition: color 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.social a:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--rule));
  transform: translateY(-1px);
}
.social a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Certification badges */
.badges {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}
.badges img {
  display: block;
  width: 92px;
  height: 92px;
  transition: transform 150ms ease;
}
.badges a:hover img { transform: scale(1.06); }
.badges a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Section headings */
section { padding: 2rem 0; border-top: 1px solid var(--rule); }
section h2 {
  font-size: 1.35rem;
  margin: 0 0 1.25rem;
  letter-spacing: -0.01em;
}

/* Skills — proficiency scale legend (under the skill list) */
.skill-legend {
  margin: 2rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.55rem 1rem;
  align-items: center;
}
.legend-item { display: contents; }
.legend-item dt {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
  color: var(--fg);
}
.legend-item dd {
  margin: 0;
  color: var(--muted);
}

/* Skills */
.skill { display: block; }
.skill-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.35rem;
}
.skill-name {
  font-weight: 600;
  font-size: 0.98rem;
}
.skill-note {
  margin: 0.5rem 0 0;
  font-size: 0.87rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Experience — timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
/* the rail (neutral) and, over it, an orange fill anchored at the bottom (the
   earliest role — where I came from) that grows upward to the entry in view as
   you scroll up toward the present (height set by JS via --tl-progress) */
.timeline::before,
.timeline::after {
  content: "";
  position: absolute;
  left: 9px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
}
.timeline::before {
  top: 6px;
  background: var(--rule);
}
.timeline::after {
  height: var(--tl-progress, 0px);
  background: var(--accent);
  transition: height 280ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  .timeline::after, .tl-marker { transition: none; }
}
.tl-item {
  position: relative;
  padding: 0 0 1.75rem 2.25rem;
  max-width: 75ch;
}
.tl-item:last-child { padding-bottom: 0.25rem; }
.tl-marker {
  position: absolute;
  left: 2px;
  top: 8px;
  width: 16px;
  height: 16px;
  background: var(--bg);
  border: 2px solid var(--rule);
  border-radius: 50%;
  z-index: 1;
  transition: border-color 250ms ease, background 250ms ease, box-shadow 250ms ease;
}
/* highlight the entry in view; before JS runs (no .is-active anywhere) the
   first entry stays lit */
.timeline:not(:has(.is-active)) .tl-item:first-child .tl-marker,
.tl-item.is-active .tl-marker {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.tl-dates {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 0 0 0.2rem;
}
.tl-dates .sep { opacity: 0.5; padding: 0 0.15rem; }
.tl-dates .current {
  color: var(--accent);
  font-weight: 600;
}
.tl-role {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: -0.005em;
}
.tl-company {
  margin: 0.1rem 0 0;
  font-size: 0.95rem;
  color: var(--fg);
}
.tl-company a { color: var(--fg); border-bottom: 1px dotted var(--muted); }
.tl-company a:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }
.tl-location { color: var(--muted); margin-left: 0.15rem; }
.tl-overview {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}
.tl-position {
  margin-top: 0.9rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--rule);
}
.tl-position:first-of-type {
  margin-top: 0.6rem;
  padding-top: 0;
  border-top: none;
}
.tl-bullets {
  margin: 0.5rem 0 0;
  padding-left: 1.05rem;
}
.tl-bullets li {
  margin: 0.25rem 0;
  font-size: 0.94rem;
}

/* Generic pages (cv.md, etc.) — keep prose readable even in a wide shell */
.page { padding: 2rem 0; max-width: 820px; }
.page-head h1 { margin: 0 0 0.35rem; font-size: 1.8rem; }
.page-desc { color: var(--muted); margin: 0 0 1.5rem; }
.page-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.93rem;
  margin: 1rem 0;
}
.page-body th, .page-body td {
  border-bottom: 1px solid var(--rule);
  padding: 0.45rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.page-body code {
  background: var(--card);
  border: 1px solid var(--rule);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}
.page-body blockquote {
  border-left: 3px solid var(--rule);
  margin: 1rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--muted);
}

/* Skills — tool list inside an expanded category */
.tool-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.1rem 2rem;
}

/* Accordion — contained, expandable cards in a responsive multi-column grid.
   Shared by Skills (categories → tools) and Presentations (talks). */
.accordion {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  align-items: start;
}
.accordion > li {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.accordion > li:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--rule));
}
.accordion > li:has(details[open]) {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--rule));
  box-shadow: 0 1px 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.accordion summary {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  list-style: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

.acc-chevron {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.15rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 200ms ease;
}
.accordion details[open] .acc-chevron { transform: rotate(45deg); }

/* Skills accordion — category-specific bits */
.skill-accordion summary:hover .skill-name { color: var(--accent); }

/* head fills the row; name + count sit left, dots pinned to the right edge */
.skill-accordion summary .skill-head { flex: 1 1 auto; min-width: 0; gap: 0.55rem; }
.skill-accordion .skill-head,
.acc-body .skill-head { align-items: center; margin-bottom: 0; }
.skill-accordion summary .skill-dots { margin-left: auto; }

/* tool-count badge on category headers */
.acc-count {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  line-height: 1;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
}
details[open] > summary .acc-count {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--rule));
}

.acc-body {
  padding: 0.2rem 1rem 1.1rem;
  border-top: 1px solid var(--rule);
  margin: 0.2rem 0 0;
}
.acc-body .skill-note { margin: 0.8rem 0 1rem; }
/* tools flow into as many columns as the card width allows: a narrow card
   shows one, a wide (spanned) card balances into two or three */
.acc-body .tool-list {
  margin: 0;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem 1.75rem;
}

/* a data-dense category (7+ tools) always claims two grid tracks, so opening it
   doesn't reflow the grid and its tools lay out in multiple columns instead of
   one long stack. Guarded to wider viewports where a second track exists. */
@media (min-width: 760px) {
  .skill-accordion > li:has(.tool-list > li:nth-child(7)) {
    grid-column: span 2;
  }
}

/* Proficiency dots (1–5 circles, coloured by level) */
[data-level="1"] { --dot-color: var(--lvl-1); }
[data-level="2"] { --dot-color: var(--lvl-2); }
[data-level="3"] { --dot-color: var(--lvl-3); }
[data-level="4"] { --dot-color: var(--lvl-4); }
[data-level="5"] { --dot-color: var(--lvl-5); }
.skill-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}
.skill-dots .dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--rule);
  transition: background 200ms ease, border-color 200ms ease;
}
.skill-dots .dot.on {
  background: var(--dot-color, var(--accent));
  border-color: var(--dot-color, var(--accent));
}

/* Presentations — always-visible talk cards in a multi-column grid */
.talks-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  align-items: start;
}
.talk {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  transition: border-color 200ms ease;
}
.talk:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--rule)); }
.talk-head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.talk-title-text {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.35;
  letter-spacing: -0.005em;
}
.talk-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.talk-venue { color: var(--accent); font-weight: 600; }
.talk-date {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.talk-summary {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
}
.talk-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: auto;
  padding-top: 0.4rem;
}
.talk-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.talk-tags li {
  font-size: 0.74rem;
  line-height: 1.2;
  padding: 0.24rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
}
.talk-link {
  margin-left: auto;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.3rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--rule));
  border-radius: 999px;
  transition: background 150ms ease, border-color 150ms ease;
}
.talk-link:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: var(--accent);
  text-decoration: none;
}

/* Footer */
.site-footer {
  max-width: var(--maxw);
  margin: 3rem auto 2rem;
  padding: 1.5rem 1.25rem 0;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer .links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.site-footer .meta { margin: 0; }
