:root {
  /* Color palettes */
  --bg-light: #f5f5f5;
  --panel-light: #ffffff;
  --text-light: #1a1a1a;
  --divider-light: #dddddd;
  --shadow-light: rgba(0, 0, 0, 0.08);
  --link-light: #226a88;
  --heading-light: #c22757;
  --heading-h3-light: #a01c3f;
  --subtext-light: #544b39;

  --bg-dark: #0f1115;
  --panel-dark: #151922;
  --text-dark: #e8e8e8;
  --divider-dark: #2b2f3a;
  --shadow-dark: rgba(0, 0, 0, 0.4);
  --link-dark: #8ac8ff;
  --heading-dark: #ff6f9c;
  --heading-h3-dark: #ff4f86;
  --subtext-dark: #b3a58a;

  --accent: #c22757;

  /* Default (light) tokens */
  --bg: var(--bg-light);
  --panel: var(--panel-light);
  --text: var(--text-light);
  --divider: var(--divider-light);
  --shadow: var(--shadow-light);
  --link: var(--link-light);
  --heading: var(--heading-light);
  --heading-h3: var(--heading-h3-light);
  --subtext: var(--subtext-light);

  /* Layout */
  --container-max: 1220px;
  --panel-padding-y: 1.5rem;
  --panel-padding-x: 2rem;
  --panel-gap: 2rem;            /* between header/main/earlier/footer sections */
  --col-gap: 6rem;              /* main - sidebar gap */
  --section-gap: 1rem;          /* columns */
  --entry-gap: 2rem;            /* experience entries */
}

/* Follows user preference for dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--bg-dark);
    --panel: var(--panel-dark);
    --text: var(--text-dark);
    --divider: var(--divider-dark);
    --shadow: var(--shadow-dark);
    --link: var(--link-dark);
    --heading: var(--heading-dark);
    --heading-h3: var(--heading-h3-dark);
    --subtext: var(--subtext-dark);
  }
}

/* toggle the current scheme */
:root:has(#theme-toggle:checked) {
  --bg: var(--bg-dark);
  --panel: var(--panel-dark);
  --text: var(--text-dark);
  --divider: var(--divider-dark);
  --shadow: var(--shadow-dark);
  --link: var(--link-dark);
  --heading: var(--heading-dark);
  --heading-h3: var(--heading-h3-dark);
  --subtext: var(--subtext-dark);
}
@media (prefers-color-scheme: dark) {
  :root:has(#theme-toggle:checked) {
    --bg: var(--bg-light);
    --panel: var(--panel-light);
    --text: var(--text-light);
    --divider: var(--divider-light);
    --shadow: var(--shadow-light);
    --link: var(--link-light);
    --heading: var(--heading-light);
    --heading-h3: var(--heading-h3-light);
    --subtext: var(--subtext-light);
  }
}

:root { color-scheme: light dark; }

*,
*::before,
*::after { box-sizing: border-box; }

:target { scroll-margin-top: 1.5rem; }

body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  margin: 0;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1, h2 { color: var(--heading); }
h3 { color: var(--heading-h3); }
h4 { color: var(--subtext); }

h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  color: inherit;
  text-decoration: none;
}
h1 a:hover { text-decoration: none; }
h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover { text-decoration: underline; }
h1 a:focus-visible,
h2 a:focus-visible,
h3 a:focus-visible,
h4 a:focus-visible,
h5 a:focus-visible,
h6 a:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

a:focus:not(:focus-visible) { outline: none; }

h2 .anchor,
h3 .anchor,
h4 .anchor {
  margin-left: 0.4rem;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  font-weight: normal;
  color: var(--link);
  position: relative;
}
h2:hover .anchor,
h2:focus-within .anchor,
h3:hover .anchor,
h3:focus-within .anchor,
h4:hover .anchor,
h4:focus-within .anchor { opacity: 1; }

.resume-header,
.layout,
.panel-section,
.site-footer {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto var(--panel-gap);
  padding: var(--panel-padding-y) var(--panel-padding-x);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow);
}

.layout {
  display: flex;
  flex-direction: column;
  gap: var(--panel-gap);
  position: relative;
  z-index: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr);
  gap: var(--col-gap);
  align-items: start;
}

.main-content { grid-column: 1; }

.sidebar {
  grid-column: 2;
  padding-left: 2rem;
  border-left: 5px dotted var(--divider);
}

.resume-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2.5rem;
  position: relative;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: var(--bg);
  padding: 8px 12px;
  z-index: 1000;
  text-decoration: none;
  font-weight: bold;
  border-radius: 0 0 4px 4px;
  transition: top 0.3s ease;
}
.skip-link:focus { top: 0; }

.profile-image img {
  width: 125px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  border: 2px solid #aaa;
}

.header-main { flex: 1; min-width: 200px; }
.header-main h1 { margin: 0 0 0.6rem; font-size: 2.5rem; }
.subtitle { margin: 0; font-size: 1.2rem; color: var(--subtext); }

.contact-info {
  position: relative;
  min-width: 250px;
  text-align: left;
  font-size: 16px;
  font-weight: 400;
  line-height: 20px;
  color: var(--subtext);
}
.contact-info p { margin: 0 0 4px 0; }
.contact-info a { color: inherit; text-decoration: none; }
.contact-info a:hover,
.contact-info a:focus-visible { color: var(--accent); text-decoration: underline; }

.header-actions {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.pillbtn {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--divider);
  border-radius: 9999px;
  box-shadow: 0 1px 3px var(--shadow);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.pillbtn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
#theme-toggle:focus-visible + .pillbtn {
  border-color: var(--accent);
  color: var(--accent);
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.main-content section { margin-bottom: var(--section-gap); }

.experience-section { padding-bottom: 0.5rem; }

.experience-entry { margin-bottom: var(--entry-gap); }
.experience-entry h4 { margin: 1em 0 0.2em; }
.experience-entry h4 + ul { margin-top: 0.25rem; }
.experience-header { display: block; }

.experience-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.experience-meta {
  margin-top: 0.25rem;
  font-size: 0.9rem;
  color: var(--subtext);
}

.experience-entry p { margin: 0.5rem 0; }
.experience-entry ul { margin: 0.5rem 0 0; padding-left: 1.5rem; }

.sidebar section {
  margin-bottom: var(--section-gap);
  padding-bottom: 0.75rem;
}
.sidebar h2 {
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--heading);
}
.sidebar h3 {
  margin: 0 0 0.25rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--subtext);
}
.sidebar h4 {
  margin: 0 0 0.25rem 0;
  color: var(--subtext);
}
.sidebar ul li { color: var(--text); }

.cert-list {
  list-style: disc;
  padding-left: 1.5rem;
  margin: 0;
}
.cert-list li { margin-bottom: 1rem; }
.cert-list a {
  font-weight: bold;
  color: var(--link);
  text-decoration: none;
}
.cert-list a:hover,
.cert-list a:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}
.cert-list .issuer,
.cert-list .date {
  font-size: 0.85em;
  color: var(--subtext);
  line-height: 1.4;
}

#earlier-career .experience-meta {
  font-size: 0.9rem;
  color: var(--subtext);
}

.site-footer nav {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-links li a {
  font-weight: bold;
  font-size: 0.95rem;
  color: var(--link);
  text-decoration: none;
}
.footer-links li a:hover,
.footer-links li a:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}
.footer-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dotted var(--divider);
}
.footer-meta p { margin: 0; }
#views-count {
  font-variant-numeric: tabular-nums;
  display: inline-block;
  min-width: 4ch;
}

/* Screen-reader only (accessible) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* < 768px (mobile) */
@media (max-width: 768px) {
  .resume-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: var(--section-gap);
  }

  .main-content,
  .sidebar { grid-column: 1; }

  .sidebar {
    border-left: none;
    border-top: 3px dotted var(--divider);
    padding-left: 0;
    padding-top: 1rem;
  }
}

/* > 1600px (ultra wide) */
@media (min-width: 1600px) {
  body { font-size: 1.1rem; }
  .header-main h1 { font-size: 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .skip-link { transition: none; }
}

@media print {
  @page { size: A4; margin: 12mm; }

  :root {
    --bg: #ffffff;
    --panel: #ffffff;
  }

  body {
    background: #ffffff;
    padding: 0;
  }

  .resume-header,
  .layout,
  .panel-section,
  .site-footer {
    box-shadow: none;
    border-radius: 0;
    margin: 0 0 1rem;
    padding: 0;
  }

  .content-grid { display: block; }
  .sidebar { border: 0; padding: 0; }
  .sidebar section + section { margin-top: 6mm; }
  #visitor-counter,
  .footer-links,
  .anchor,
  .header-actions { display: none !important; }

  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.9em;
  }

  /* Avoid breaking inside key blocks */
  .experience-entry,
  .experience-entry ul,
  .experience-entry ol,
  .cert-list,
  .cert-list li,
  .sidebar section,
  #earlier-career .experience-entry {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Keep headings with following content */
  h2, h3, h4 {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Keep first list item with its heading/intro paragraph */
  h2 + p, h3 + p, h4 + p,
  h2 + ul, h3 + ul, h4 + ul,
  h2 + ol, h3 + ol, h4 + ol {
    break-before: avoid;
    page-break-before: avoid;
  }

  p { orphans: 3; widows: 3; }

  .page-break {
    break-before: page;
    page-break-before: always;
  }
}
