/**
 * @project       J. Gregory Walsh – Career Profile Website (https://jgwalsh.com)
 * @description   Main stylesheet for all pages.
 * @version       1.3.0
 */

/* --- Base & Root Configuration --- */
:root {
  --color-navy: #1e3a8a;
  --color-navy-700: #152859;
  --color-slate-50: #f6f8fb;
  --color-slate-200: #e2e8f0;
  --color-slate-300: #cfd7e4;
  --color-slate-700: #1f2937;
  --color-slate-900: #0f172a;
  --color-white: #ffffff;
  --color-teal-50: #e0f4f4;
  --color-teal-100: #c0e8e8;
  --color-teal-200: #9edada;
  --color-teal-300: #6fc3c3;
  --color-teal-400: #3aa9aa;
  --color-teal-500: #008080;
  --color-teal-600: #006a6a;
  --color-teal-700: #004f4f;

  /* Core surfaces */
  --bg: var(--color-slate-50);
  --surface: var(--color-white);
  --surface-muted: #eef3f9;
  --surface-strong: #dce5f3;

  /* Typography */
  --text: var(--color-slate-900);
  --muted: #475467;
  --link: var(--color-navy);

  /* Interaction tokens */
  --border: var(--color-slate-300);
  --btn-bg: var(--color-teal-500);
  --btn-text: var(--color-white);
  --ring: var(--color-teal-500);

  /* Brand + accent system */
  --brand: var(--color-navy);
  --brand-strong: var(--color-navy-700);
  --accent: var(--color-teal-500);
  --accent-muted: var(--color-teal-100);
  --accent-strong: var(--color-teal-600);

  /* Content surfaces */
  --ink: var(--text);
  --ink-muted: var(--muted);
  --card: var(--surface);
  --card-muted: var(--surface-muted);
  --bd: color-mix(in srgb, var(--border) 90%, transparent);
  --shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
  --chip: color-mix(in srgb, var(--accent-muted) 65%, white 35%);
  --chip-ink: var(--accent-strong);

  /* Navigation + footer */
  --nav-bg: rgba(255, 255, 255, 0.92);
  --nav-border: rgba(15, 23, 42, 0.08);
  --nav-shadow: 0 22px 48px rgba(15, 23, 42, 0.12);
  --nav-link: var(--ink);
  --nav-link-hover: var(--accent);
  --nav-link-active: var(--accent);
  --footer-bg: var(--surface-muted);
  --footer-text: #1f2937;
  --footer-link: var(--accent);
  --footer-border: color-mix(in srgb, var(--border) 80%, transparent);

  /* Motion-safe layout cadence */
  --grid-gap: clamp(1.25rem, 3vw, 2.5rem);

  /* Tailored switches */
  --color-bg: var(--bg);
  --color-text: var(--text);
  --color-accent: var(--accent);
  --switch-track-light: color-mix(in srgb, var(--accent-muted) 55%, white 45%);
  --switch-track-dark: #223041;
  --switch-thumb-light: var(--color-white);
  --switch-thumb-dark: #0f141a;
  --switch-track: var(--switch-track-light);
  --switch-thumb: var(--switch-thumb-light);
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  line-height: 1.6;
}

/* Dark theme */
html[data-theme="dark"] {
  --bg: #060b12;
  --surface: #0f172a;
  --surface-muted: #111d2e;
  --surface-strong: #1f2a3d;
  --text: #e3e9f5;
  --muted: #9ba9c0;
  --link: #9ec5ff;
  --border: #1f2a3d;
  --btn-bg: #199191;
  --btn-text: #e7f8f8;
  --ring: #2ab3b3;
  --brand: #95b3ff;
  --brand-strong: #6e8ae0;
  --accent: #2ab3b3;
  --accent-muted: #123f4d;
  --accent-strong: #57d6d6;
  --ink: var(--text);
  --ink-muted: var(--muted);
  --card: #101c2d;
  --card-muted: #0f1a27;
  --bd: rgba(148, 163, 184, 0.35);
  --shadow: 0 28px 60px rgba(2, 6, 23, 0.65);
  --chip: #12313f;
  --chip-ink: #c8e8e8;
  --nav-bg: rgba(6, 11, 18, 0.94);
  --nav-border: rgba(148, 163, 184, 0.24);
  --nav-shadow: 0 26px 52px rgba(2, 6, 23, 0.7);
  --nav-link: var(--text);
  --nav-link-hover: var(--accent);
  --nav-link-active: var(--accent);
  --footer-bg: #0a111b;
  --footer-text: #d4deec;
  --footer-link: #57d6d6;
  --footer-border: rgba(87, 214, 214, 0.22);
  --color-bg: var(--bg);
  --color-text: var(--text);
  --color-accent: var(--accent);
  --switch-track: var(--switch-track-dark);
  --switch-thumb: var(--switch-thumb-dark);
}

/* Threat Triage: page layout & footer fix (scoped) */
.triage-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.triage-footer {
  padding: 1rem 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
}

.triage-footer .footer-links a {
  color: var(--text);
  text-decoration: none;
}

.triage-footer .footer-links a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- Layout & Structure --- */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-grow {
  flex-grow: 1;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-4 {
  gap: 1rem;
}

.min-h-screen {
  min-height: 100vh;
}

.max-w-6xl,
.max-w-4xl,
.max-w-md {
  margin-left: auto;
  margin-right: auto;
}

.max-w-6xl {
  max-width: 72rem;
}

.max-w-4xl {
  max-width: 56rem;
}

.max-w-md {
  max-width: 28rem;
}

.w-full {
  width: 100%;
}

.sticky {
  position: sticky;
}

.top-0 {
  top: 0;
}

.z-50 {
  z-index: 50;
}

.grid {
  display: grid;
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* --- Spacing, Borders, Shadows --- */
.p-2 {
  padding: 0.5rem;
}

.p-3 {
  padding: 0.75rem;
}

.p-8 {
  padding: 2rem;
}

.pt-6 {
  padding-top: 1.5rem;
}

.pt-8 {
  padding-top: 2rem;
}

.pb-6 {
  padding-bottom: 1.5rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.py-5 {
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
}

.py-12 {
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.mt-auto {
  margin-top: auto;
}

.space-y-4> :not([hidden])~ :not([hidden]) {
  margin-top: 1rem;
}

.space-y-6> :not([hidden])~ :not([hidden]) {
  margin-top: 1.5rem;
}

.rounded-lg {
  border-radius: 0.5rem;
}

.rounded-xl {
  border-radius: 0.75rem;
}

.rounded-full {
  border-radius: 9999px;
}

.border-t {
  border-top-width: 1px;
}

.shadow-sm {
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.ring-4 {
  box-shadow: 0 0 0 4px var(--color-white);
}

/* Simplified ring */

/* --- Typography & Colors --- */
.text-navy {
  color: var(--color-navy);
}

.text-sage {
  color: var(--color-sage);
}

.text-white {
  color: var(--color-white);
}

.text-gray-400 {
  color: var(--color-gray-400);
}

.text-gray-500 {
  color: var(--color-gray-500);
}

.text-gray-700 {
  color: var(--color-gray-700);
}

.text-2xl {
  font-size: 1.5rem;
}

.text-3xl {
  font-size: 1.875rem;
}

.text-4xl {
  font-size: 2.25rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.font-medium {
  font-weight: 500;
}

.text-center {
  text-align: center;
}

.block {
  display: block;
}

.bg-white {
  background-color: var(--color-white);
}

.bg-gray-50 {
  background-color: var(--color-gray-50);
}

.bg-gray-100 {
  background-color: var(--color-gray-100);
}

.bg-sage {
  background-color: var(--color-sage);
}

.bg-navy\/10 {
  background-color: rgba(30, 58, 138, 0.1);
}

.opacity-70 {
  opacity: 0.7;
}

/* --- Interactivity & Transitions --- */
.transition {
  transition-property: all;
  transition-duration: 150ms;
}

.hover\:text-navy:hover {
  color: var(--color-navy);
}

.hover\:bg-gray-200:hover {
  background-color: var(--color-gray-200);
}

.hover\:bg-sage\/90:hover {
  background-color: rgba(75, 110, 93, 0.9);
}

.hover\:underline:hover {
  text-decoration: underline;
}

.group:hover .group-hover\:text-navy {
  color: var(--color-navy);
}

.group:hover .group-hover\:text-lime-600 {
  color: var(--color-lime-600);
}

.group:hover .group-hover\:text-amber-500 {
  color: var(--color-amber-500);
}

.group:hover .group-hover\:text-red-600 {
  color: var(--color-red-600);
}

.group:hover .group-hover\:opacity-100 {
  opacity: 1;
}

/* --- Navigation --- */
.hidden {
  display: none;
}

#mobile-menu a {
  display: block;
  padding: 0.5rem 0;
}

@media (min-width: 640px) {
  .sm\:hidden {
    display: none;
  }

  .sm\:flex {
    display: flex;
  }
}

/* Global interactive elements */
a {
  color: var(--link);
}

button {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--border);
}

.theme-toggle {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: .375rem .5rem;
  border-radius: 6px;
  cursor: pointer;
}

.theme-toggle:focus-visible,
a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* Footer styles: do not alter hrefs; style only */
footer,
.site-footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  border-top: 1px solid var(--footer-border);
  text-align: center;
}

footer a {
  color: var(--footer-link);
}

/* Footer icon links: keep sizes and brand colors */
footer a img,
footer a svg {
  width: 20px;
  height: 20px;
  display: inline-block;
  filter: none !important;
  mix-blend-mode: normal !important;
  opacity: 1 !important;
}

/* Optional: larger tap targets without changing hrefs */
footer a.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

footer a.icon-link:focus-visible {
  outline: 2px solid var(--footer-link);
  outline-offset: 3px;
}

/* === Theme + switch tokens (safe defaults) === */
:root {
  --color-bg: var(--bg);
  --color-text: var(--text);
  --color-accent: var(--accent);
  /* aliases used by components */
  --switch-track: var(--switch-track-light);
  --switch-thumb: var(--switch-thumb-light);
}

:root[data-theme="dark"] {
  --color-bg: var(--bg);
  --color-text: var(--text);
  /* flip aliases in dark */
  --switch-track: var(--switch-track-dark);
  --switch-thumb: var(--switch-thumb-dark);
}

/* Apply tokens (no global invert) */
html,
body {
  background: var(--color-bg);
  color: var(--color-text);
}

img,
svg {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* --- Project card image safety --- */
.project-card-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: cover;
  border-radius: 8px;
}

/* --- GPT buttons row --- */
.gpt-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  margin: 2rem auto 3rem;
  max-width: 1100px;
  padding: 0 1rem;
}

.gpt-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid #d0d0d0;
  border-radius: 10px;
  background: #f8f8f8;
  color: #111;
  line-height: 1;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.gpt-button:hover {
  transform: translateY(-1px);
  background: #f1f1f1;
  border-color: #c0c0c0;
}

.gpt-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
}

.gpt-button:focus-visible {
  outline: 2px solid #008080;
  outline-offset: 2px;
}

/* === Sliding Switch === */
.theme-toggle {
  /* mobile-first sizing with clamp() scales on tablets/desktop */
  --h: clamp(28px, 2.8vh, 34px);
  --w: calc(var(--h) * 1.9);
  --pad: 3px;
  --thumb: calc(var(--h) - var(--pad)*2);
  --speed: 220ms;
  display: inline-flex;
  align-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 9999px;
  position: relative;
  touch-action: manipulation;
}

@media (max-width: 640px) {
  .theme-toggle {
    padding: 8px 6px;
  }
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  border-radius: 9999px;
}

.theme-toggle__track {
  width: var(--w);
  height: var(--h);
  background: var(--switch-track);
  border-radius: 9999px;
  position: relative;
  transition: background var(--speed) ease;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  border-radius: 9999px;
}

.theme-toggle__thumb {
  width: var(--thumb);
  height: var(--thumb);
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  border-radius: 50%;
  background: var(--switch-thumb);
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: left var(--speed) ease, background var(--speed) ease, transform var(--speed) ease;
  will-change: left, transform;
}

:root[data-theme="dark"] .theme-toggle__thumb {
  left: calc(var(--w) - var(--thumb) - var(--pad));
  background: var(--switch-thumb-dark);
}

/* Icon sizing + crossfade */
.theme-toggle__thumb .icon {
  width: clamp(14px, 2.2vh, 16px);
  height: clamp(14px, 2.2vh, 16px);
  display: block;
  transition: opacity var(--speed) ease, transform var(--speed) ease;
}

.theme-toggle__thumb .icon--sun {
  fill: currentColor;
  color: #f59e0b;
  stroke: currentColor;
  opacity: 1;
  transform: translateY(0);
}

.theme-toggle__thumb .icon--moon {
  fill: currentColor;
  color: #cbd5e1;
  opacity: 0;
  transform: translateY(4px) scale(.92);
}

:root[data-theme="dark"] .theme-toggle__thumb .icon--sun {
  opacity: 0;
  transform: translateY(-4px) scale(.92);
}

:root[data-theme="dark"] .theme-toggle__thumb .icon--moon {
  opacity: 1;
  transform: translateY(0);
}

/* Subtle hover lift (respects motion prefs) */
.theme-toggle:hover .theme-toggle__thumb {
  transform: translateY(-1px);
}

:root[data-theme="dark"] .theme-toggle:hover .theme-toggle__thumb {
  transform: translate(-1px, -1px);
}

@media(prefers-reduced-motion:reduce) {

  .theme-toggle__thumb,
  .theme-toggle__track,
  .theme-toggle__thumb .icon {
    transition: none;
  }
}

/* === Minimal switch (no icons/text) === */
/* Never invert imagery anywhere */
img,
svg {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Mobile-first sizing with clamp() */
.theme-toggle {
  --h: clamp(22px, 2.2vh, 28px);
  --w: calc(var(--h) * 1.9);
  --pad: 2px;
  --thumb: calc(var(--h) - var(--pad)*2);
  --speed: 200ms;

  display: inline-flex;
  align-items: center;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  border-radius: 9999px;
  cursor: pointer;
  touch-action: manipulation;
}

.theme-toggle:focus-visible {
  outline: 2px solid #008080;
  outline-offset: 4px;
  border-radius: 9999px;
}

/* Track */
.switch__track {
  width: var(--w);
  height: var(--h);
  border-radius: 9999px;
  position: relative;
  background: var(--switch-track, #d1d5db);
  transition: background var(--speed) ease, box-shadow var(--speed) ease;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}

/* Thumb */
.switch__thumb {
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: left var(--speed) ease, transform var(--speed) ease, background var(--speed) ease;
  will-change: left, transform;
}

/* ON state (dark theme) — slide right and darken track */
:root[data-theme="dark"] .switch__track {
  background: #1f2937;
  /* slate-800 */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
}

:root[data-theme="dark"] .switch__thumb {
  left: calc(var(--w) - var(--thumb) - var(--pad));
  background: #0f141a;
}

/* Hover micro-lift (honor reduced motion) */
.theme-toggle:hover .switch__thumb {
  transform: translateY(-0.5px);
}

:root[data-theme="dark"] .theme-toggle:hover .switch__thumb {
  transform: translate(-0.5px, -0.5px);
}

@media (prefers-reduced-motion: reduce) {

  .switch__track,
  .switch__thumb {
    transition: none;
  }
}

/* === Header v2 (scoped) === */
.site-header {
  width: min(100% - 2.5rem, 1080px);
  margin: 0 auto;
  padding-inline: clamp(1rem, 4vw, 1.75rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.75rem;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

header.sticky {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  transition: background .3s ease, box-shadow .3s ease, border-color .3s ease;
}

header.sticky .brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
}

header.sticky img {
  filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.25));
}

html[data-theme="dark"] header.sticky {
  background: rgba(15, 18, 27, 0.9);
  border-color: rgba(148, 163, 184, 0.18);
  box-shadow: 0 18px 44px rgba(2, 6, 23, 0.55);
}

header.sticky nav a {
  transition: color .25s ease, background .25s ease;
}

.brand-mark {
  width: 22px;
  height: 22px;
  display: block;
}

.nav-link {
  padding: .4rem .55rem;
  border-radius: 8px;
  text-decoration: none;
}

.nav-link:hover {
  background: color-mix(in hsl, var(--brand) 10%, transparent);
}

.nav-link.is-current {
  color: var(--ink);
  font-weight: 600;
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.mobile-nav .mobile-link {
  display: block;
  padding: .6rem .5rem;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
}

.mobile-nav .mobile-link.is-current {
  font-weight: 600;
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Theme toggle visual states (desktop & mobile share this) */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block;
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  background: var(--ink);
  position: relative;
  left: 3px;
  top: 3px;
  transition: transform .18s ease;
  display: inline-block;
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(18px);
}

.dark .theme-toggle .switch__track {
  background: color-mix(in hsl, var(--brand) 25%, var(--bg));
  border-color: var(--bd);
}

.dark .theme-toggle .switch__thumb {
  background: #fff;
}

/* === Résumé sheet: dark-mode readability === */
.resume-sheet {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.dark .resume-sheet {
  background: var(--card);
  color: var(--ink);
}

/* Make all standard text readable inside the sheet */
.dark .resume-sheet p,
.dark .resume-sheet li,
.dark .resume-sheet dd {
  color: var(--ink);
}

/* Headings & subtitles inside the sheet */
.dark .resume-sheet h1,
.dark .resume-sheet h2,
.dark .resume-sheet h3,
.dark .resume-sheet h4 {
  color: var(--ink);
}

.dark .resume-sheet .subtitle,
.dark .resume-sheet .lead,
.dark .resume-sheet small {
  color: var(--muted);
}

/* Lists, markers and spacing */
.resume-sheet ul,
.resume-sheet ol {
  padding-left: 1.15rem;
}

.dark .resume-sheet li::marker {
  color: var(--muted);
}

/* Dividers */
.dark .resume-sheet hr {
  border-color: var(--bd);
  opacity: 1;
}

/* Tables (if present) */
.dark .resume-sheet table {
  width: 100%;
  border-collapse: collapse;
  border-color: var(--bd);
}

.dark .resume-sheet th,
.dark .resume-sheet td {
  border-color: var(--bd);
}

.dark .resume-sheet thead th {
  background: color-mix(in hsl, var(--card) 60%, var(--bg));
  color: var(--ink);
}

.dark .resume-sheet tbody tr:nth-child(2n) {
  background: color-mix(in hsl, var(--card) 85%, var(--bg));
}

/* Code / pre / quotes */
.dark .resume-sheet code {
  background: color-mix(in hsl, var(--card) 80%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 6px;
  padding: .1rem .3rem;
}

.dark .resume-sheet pre {
  background: color-mix(in hsl, var(--card) 70%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 8px;
  padding: .75rem;
  overflow: auto;
}

.dark .resume-sheet blockquote {
  color: var(--muted);
  border-left: 3px solid var(--ring);
  padding-left: .75rem;
  margin-left: 0;
}

/* Ensure links are visible */
.dark .resume-sheet a {
  color: color-mix(in hsl, var(--brand) 85%, white 0%);
  text-decoration: none;
}

.dark .resume-sheet a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* === Dark-mode readability: Home + Contact (scoped) === */

/* 1) Home: Core Competencies section */
.dark .core-competencies {
  background: #111827;
  /* deep slate backdrop */
  color: #e5e7eb;
  /* light gray text */
}

/* Headings + body text inside the section */
.dark .core-competencies h2,
.dark .core-competencies h3 {
  color: #f3f4f6;
}

.dark .core-competencies p,
.dark .core-competencies li {
  color: #d1d5db;
}

.dark .core-competencies li::marker {
  color: var(--muted);
}

/* Cards inside Core Competencies */
.dark .core-competencies .card,
.dark .core-competencies .competency-card,
.dark .core-competencies .resume-card,
.dark .core-competencies .section {
  background: #1f2937;
  /* dark card surface */
  border: 1px solid #374151;
  /* subtle border */
  border-radius: 14px;
  box-shadow: var(--shadow);
  color: #f9fafb;
  /* near-white text */
}

/* Links in Core Competencies */
.dark .core-competencies a {
  color: color-mix(in hsl, var(--brand) 85%, white 0%);
  text-decoration: none;
}

.dark .core-competencies a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* 2) Contact: main contact card */
.contact-card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.dark .contact-card {
  background: #1f2937;
  border-color: #374151;
  color: #f9fafb;
}

.dark .contact-card h1,
.dark .contact-card h2,
.dark .contact-card h3 {
  color: #f3f4f6;
}

.dark .contact-card p,
.dark .contact-card li,
.dark .contact-card label {
  color: #e5e7eb;
}

.dark .contact-card small,
.dark .contact-card .muted {
  color: var(--muted);
}

.dark .contact-card a {
  color: #93c5fd;
  text-decoration: none;
}

.dark .contact-card a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dark .contact-card hr {
  border-color: var(--bd);
  opacity: 1;
}

/* Ensure icons/logos remain natural in dark mode */
.dark .contact-card img,
.dark .contact-card svg {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* === General mobile safety (scoped to home to avoid dupes) === */
.home-sheet img,
.home-sheet video,
.home-sheet iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

.home-sheet pre {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* === HERO tuning (home) === */
.hero {
  position: relative;
  padding: clamp(3rem, 9vw, 6rem) 1rem;
  text-align: center;
  overflow: hidden;
  isolation: isolate;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  width: clamp(320px, 60vw, 520px);
  aspect-ratio: 1;
  border-radius: 9999px;
  background: radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.18), transparent 65%);
  z-index: -1;
  filter: blur(4px);
  pointer-events: none;
}

.hero::before {
  top: -18%;
  left: 45%;
}

.hero::after {
  bottom: -35%;
  right: 40%;
  background: radial-gradient(circle at 50% 50%, rgba(52, 211, 153, 0.16), transparent 68%);
}

.hero h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(1.9rem, 6.2vw, 2.8rem);
  letter-spacing: -.01em;
}

.hero p {
  max-width: 720px;
  margin: 0 auto 1.25rem;
  color: #444;
  font-size: clamp(1rem, 2.4vw, 1.125rem);
  line-height: 1.6;
}

.hero .cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
}

.hero .cta-group a {
  position: relative;
  padding: .75rem 1.4rem;
  border-radius: 9999px;
  font-weight: 600;
  border: 1px solid transparent;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.85), rgba(59, 130, 246, 0.65));
  color: #fff;
  box-shadow: 0 12px 32px rgba(59, 130, 246, 0.25);
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease, border-color .25s ease, color .25s ease;
}

.hero .cta-group a:nth-child(2) {
  background: rgba(255, 255, 255, 0.85);
  color: #1f2937;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.hero .cta-group a:nth-child(3) {
  background: rgba(16, 24, 40, 0.92);
  color: #fff;
  border-color: rgba(15, 23, 42, 0.6);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.35);
}

.hero .cta-group a:hover,
.hero .cta-group a:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
  border-color: transparent;
}

/* === Core Competencies grid (home) === */
.core {
  margin: clamp(2rem, 5vw, 3.5rem) auto;
}

.core h2 {
  font-weight: 700;
  margin-bottom: .75rem;
  letter-spacing: -.01em;
}

.core p.lead {
  max-width: 820px;
  margin: 0.25rem auto 1.75rem;
  color: #444;
  line-height: 1.6;
}

.core-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
  align-items: stretch;
}

.core-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(241, 245, 249, 0.92));
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 18px;
  padding: 1.35rem 1.35rem 1.2rem;
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.07);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  overflow: hidden;
}

.core-card::after {
  content: "";
  position: absolute;
  inset: auto auto -40% 55%;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.16), transparent 65%);
  transform: rotate(12deg);
  pointer-events: none;
}

.core-card:hover {
  transform: translateY(-6px);
  border-color: rgba(79, 70, 229, 0.35);
  box-shadow: 0 26px 48px rgba(15, 23, 42, 0.12);
}

.core-card h3 { font-size: 1.1rem; margin: 0 0 .5rem; }
.core-card ul { margin: .5rem 0 0; padding-left: 1.1rem; display: grid; gap: .55rem; }
.core-card li { margin: 0; line-height: 1.55; }
.core-card svg { color: rgba(14, 116, 144, 0.85); flex-shrink: 0; }
.core-card strong { color: #1f2937; }

@media (max-width: 1024px) {
  .core-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .core { margin: 1.5rem auto 2.25rem; }
  .core-grid { grid-template-columns: 1fr; gap: 1rem; }
  .core-card { padding: 1.1rem; border-radius: 16px; }
}

/* === Optional: small contrast nudge (scoped to hero/core only) === */
.hero h1,
.core h2,
.core h3 { color: #1a1a1a; }

.hero a,
.core a { color: #1a1a1a; }

.hero a:hover,
.core a:hover { color: #000; }

@media (prefers-color-scheme: dark) {
  .hero::before {
    background: radial-gradient(circle at 30% 30%, rgba(129, 140, 248, 0.24), transparent 65%);
  }
  .hero::after {
    background: radial-gradient(circle at 50% 50%, rgba(34, 197, 94, 0.22), transparent 68%);
  }
  .hero .cta-group a:nth-child(2) {
    background: rgba(148, 163, 184, 0.12);
    color: rgba(226, 232, 240, 0.88);
    border-color: rgba(148, 163, 184, 0.32);
  }
  .core-card {
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.88));
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: 0 18px 32px rgba(2, 6, 23, 0.45);
  }
  .core-card::after {
    background: radial-gradient(circle, rgba(94, 234, 212, 0.28), transparent 70%);
  }
  .core-card strong {
    color: rgba(226, 232, 240, 0.92);
  }
  .core-card li {
    color: rgba(203, 213, 225, 0.9);
  }
}

html.dark .hero::before {
  background: radial-gradient(circle at 30% 30%, rgba(129, 140, 248, 0.24), transparent 65%);
}

html.dark .hero::after {
  background: radial-gradient(circle at 50% 50%, rgba(34, 197, 94, 0.22), transparent 68%);
}

html.dark .hero .cta-group a:nth-child(2) {
  background: rgba(148, 163, 184, 0.12);
  color: rgba(226, 232, 240, 0.88);
  border-color: rgba(148, 163, 184, 0.32);
}

html.dark .core-card {
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.88));
  border-color: rgba(148, 163, 184, 0.18);
  box-shadow: 0 18px 32px rgba(2, 6, 23, 0.45);
}

html.dark .core-card::after {
  background: radial-gradient(circle, rgba(94, 234, 212, 0.28), transparent 70%);
}

html.dark .core-card strong {
  color: rgba(226, 232, 240, 0.92);
}

html.dark .core-card li {
  color: rgba(203, 213, 225, 0.9);
}

/* Safety: drawer visibility + toggle visuals (harmless if duplicates already exist) */
#mobile-menu.hidden {
  display: none;
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block;
  transition: background .2s ease;
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--ink);
  transition: transform .2s ease;
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(20px);
}

.dark .theme-toggle .switch__track {
  background: color-mix(in hsl, var(--brand) 25%, var(--bg));
  border-color: var(--bd);
}

.dark .theme-toggle .switch__thumb {
  background: #fff;
}

/* === Home sheet: dark-mode readability === */
.home-sheet {
  background: transparent;
}

.dark .home-sheet .section,
.dark .home-sheet .card,
.dark .home-sheet .competency-card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.dark .home-sheet h1,
.dark .home-sheet h2,
.dark .home-sheet h3 {
  color: var(--ink);
}

.dark .home-sheet p,
.dark .home-sheet li {
  color: var(--ink);
}

.dark .home-sheet li::marker {
  color: var(--muted);
}

.dark .home-sheet a {
  color: color-mix(in hsl, var(--brand) 85%, white 0%);
}

.dark .home-sheet a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* === Contact card: dark-mode readability === */
.contact-card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.dark .contact-card {
  background: var(--card);
  color: var(--ink);
}

.dark .contact-card h1,
.dark .contact-card h2,
.dark .contact-card h3 {
  color: var(--ink);
}

.dark .contact-card p,
.dark .contact-card li,
.dark .contact-card label {
  color: var(--ink);
}

.dark .contact-card small,
.dark .contact-card .muted {
  color: var(--muted);
}

.dark .contact-card a {
  color: color-mix(in hsl, var(--brand) 85%, white 0%);
  text-decoration: none;
}

.dark .contact-card a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dark .contact-card hr {
  border-color: var(--bd);
  opacity: 1;
}

.dark .contact-card img,
.dark .contact-card svg {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* drawer + toggle visuals (already present elsewhere; safe repeat) */
#mobile-menu.hidden {
  display: none;
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block;
  transition: background .2s ease;
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--ink);
  transition: transform .2s ease;
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(20px);
}

.dark .theme-toggle .switch__track {
  background: color-mix(in hsl, var(--brand) 25%, var(--bg));
  border-color: var(--bd);
}

.dark .theme-toggle .switch__thumb {
  background: #fff;
}

/* =========================================================
   Dark-mode readability polish (site-wide, non-destructive)
   ========================================================= */

/* Base legibility */
.dark body {
  background: var(--bg);
  color: var(--ink);
}

.dark p,
.dark li,
.dark dd {
  color: var(--ink);
}

.dark .muted,
.dark .subtitle,
.dark .lead,
.dark small {
  color: var(--muted);
}

/* Reading rhythm */
:root {
  --lh-body: 1.6;
  --space-paragraph: .65rem;
}

body {
  line-height: var(--lh-body);
}

p+p {
  margin-top: var(--space-paragraph);
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  margin-top: 1rem;
  margin-bottom: .5rem;
}

/* Links: higher contrast + clearer affordance */
.dark a {
  color: color-mix(in hsl, var(--brand) 85%, white 0%);
  text-decoration: none;
}

.dark a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* “Card” containers used across pages (resume sections, long blocks) */
.resume-section,
.resume-card,
.section,
.card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Dividers */
.dark hr {
  border-color: var(--bd);
  opacity: 1;
}

/* Lists */
.dark ul,
.dark ol {
  color: var(--ink);
  padding-left: 1.15rem;
}

.dark li::marker {
  color: var(--muted);
}

/* Tables */
.dark table {
  width: 100%;
  border-collapse: collapse;
  border-color: var(--bd);
}

.dark th,
.dark td {
  border-color: var(--bd);
}

.dark thead th {
  background: color-mix(in hsl, var(--card) 60%, var(--bg));
  color: var(--ink);
}

.dark tbody tr:nth-child(2n) {
  background: color-mix(in hsl, var(--card) 85%, var(--bg));
}

/* Code / pre / quote blocks */
.dark code {
  background: color-mix(in hsl, var(--card) 80%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 6px;
  padding: .1rem .3rem;
}

.dark pre {
  background: color-mix(in hsl, var(--card) 70%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 8px;
  padding: .75rem;
  overflow: auto;
}

.dark blockquote {
  color: var(--muted);
  border-left: 3px solid var(--ring);
  padding-left: .75rem;
  margin-left: 0;
}

/* Buttons (common) */
.dark .btn-primary {
  background: var(--brand);
  color: #fff;
  border: 1px solid color-mix(in hsl, var(--brand) 60%, #000);
}

.dark .btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--bd);
}

.dark .btn-primary:hover {
  filter: brightness(1.05);
}

.dark .btn-outline:hover {
  background: color-mix(in hsl, var(--brand) 10%, var(--bg));
}

/* Projects page tag pills (brighter in dark) */
.dark .pp-tagsline .pp-tag {
  background: color-mix(in hsl, var(--card) 80%, var(--bg));
  border: 1px solid var(--bd);
  color: #E5E7EB;
  /* light gray for readability */
}

/* Prevent images/logos from inverting in dark */
.dark img,
.dark svg,
.dark .logo {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Mobile drawer visibility (used by theme.js) */
#mobile-menu.hidden {
  display: none;
}

/* Theme toggle visuals (desktop + mobile) */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block;
  transition: background .2s ease;
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--ink);
  transition: transform .2s ease;
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(20px);
}

.dark .theme-toggle .switch__track {
  background: color-mix(in hsl, var(--brand) 25%, var(--bg));
  border-color: var(--bd);
}

.dark .theme-toggle .switch__thumb {
  background: #fff;
}

/* Optional: higher-contrast preference */
@media (prefers-contrast: more) {
  .dark a {
    text-decoration: underline;
  }

  :focus-visible {
    outline-width: 3px;
  }
}

/* === Résumé page (dark-mode readability) === */
.dark #resume-page {
  background: var(--bg);
  color: var(--ink);
}

/* Headings and subheads */
.dark #resume-page h1,
.dark #resume-page h2,
.dark #resume-page h3,
.dark #resume-page h4 {
  color: var(--ink);
}

.dark #resume-page .subtitle,
.dark #resume-page .lead {
  color: var(--muted);
}

/* Paragraph rhythm */
#resume-page p {
  line-height: 1.6;
}

#resume-page p+p {
  margin-top: .65rem;
}

/* “Card” wrappers for big sections (add class resume-section or resume-card in markup when possible) */
#resume-page .resume-section,
#resume-page .resume-card,
#resume-page .section,
#resume-page .card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-block: 12px;
}

/* Links: higher contrast in dark */
.dark #resume-page a {
  color: color-mix(in hsl, var(--brand) 85%, white 0%);
  text-decoration: none;
}

.dark #resume-page a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Lists */
.dark #resume-page ul,
.dark #resume-page ol {
  color: var(--ink);
  padding-left: 1.15rem;
}

.dark #resume-page li::marker {
  color: var(--muted);
}

/* Tables */
.dark #resume-page table {
  width: 100%;
  border-collapse: collapse;
  border-color: var(--bd);
}

.dark #resume-page th,
.dark #resume-page td {
  border-color: var(--bd);
}

.dark #resume-page thead th {
  background: color-mix(in hsl, var(--card) 60%, var(--bg));
  color: var(--ink);
}

.dark #resume-page tbody tr:nth-child(2n) {
  background: color-mix(in hsl, var(--card) 85%, var(--bg));
}

/* Code / pre / quotes */
.dark #resume-page code {
  background: color-mix(in hsl, var(--card) 80%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 6px;
  padding: .1rem .3rem;
}

.dark #resume-page pre {
  background: color-mix(in hsl, var(--card) 70%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 8px;
  padding: .75rem;
  overflow: auto;
}

.dark #resume-page blockquote {
  color: var(--muted);
  border-left: 3px solid var(--ring);
  padding-left: .75rem;
  margin-left: 0;
}

/* Buttons commonly used on resume */
.dark #resume-page .btn-primary {
  background: var(--brand);
  color: #fff;
  border: 1px solid color-mix(in hsl, var(--brand) 60%, #000);
}

.dark #resume-page .btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--bd);
}

.dark #resume-page .btn-primary:hover {
  filter: brightness(1.05);
}

.dark #resume-page .btn-outline:hover {
  background: color-mix(in hsl, var(--brand) 10%, var(--bg));
}

/* Ensure logos/images are not inverted in dark */
.dark #resume-page img,
.dark #resume-page svg,
.dark #resume-page .logo {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Divider visibility */
.dark #resume-page hr {
  border-color: var(--bd);
  opacity: 1;
}

/* Focus visibility */
#resume-page :focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Drawer visibility (used by theme.js) — harmless site-wide */
#mobile-menu.hidden {
  display: none;
}

/* Theme toggle visuals (shared) — harmless site-wide */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block;
  transition: background .2s ease;
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--ink);
  transition: transform .2s ease;
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(20px);
}

.dark .theme-toggle .switch__track {
  background: color-mix(in hsl, var(--brand) 25%, var(--bg));
  border-color: var(--bd);
}

.dark .theme-toggle .switch__thumb {
  background: #fff;
}

/* === /projects/ ensured slider + drawer visibility (hdr_clean1) === */
#mobile-menu.hidden {
  display: none;
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block;
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  background: var(--ink);
  position: relative;
  left: 3px;
  top: 3px;
  display: inline-block;
  transition: transform .18s ease;
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(18px);
}

.dark .theme-toggle .switch__track {
  background: color-mix(in hsl, var(--brand) 25%, var(--bg));
  border-color: var(--bd);
}

.dark .theme-toggle .switch__thumb {
  background: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle .switch__thumb {
    transition: none;
  }
}

/* Safe-area insets for iOS notch */
@supports (padding: max(0px)) {
  .header-wrap {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* == /projects/ header helpers == */
/* Ensure the drawer actually hides when the 'hidden' class is present */
#mobile-menu.hidden {
  display: none;
}

/* Theme toggle (clean spec) */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block;
  transition: background .2s ease;
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform .2s ease;
}

.dark .theme-toggle .switch__track {
  background: var(--brand);
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(20px);
  background: #fff;
}

/* === Résumé dark-mode polish (scoped but generic) === */
.dark body {
  background: var(--bg);
  color: var(--ink);
}

.dark h1,
.dark h2,
.dark h3,
.dark h4 {
  color: var(--ink);
}

.dark .subtitle,
.dark .lead {
  color: var(--muted);
}

.resume-section,
.resume-card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.dark hr {
  border-color: var(--bd);
  opacity: 1;
}

.dark ul,
.dark ol {
  color: var(--ink);
}

.dark li::marker {
  color: var(--muted);
}

.dark a {
  color: color-mix(in hsl, var(--brand) 85%, white 0%);
  text-decoration: none;
}

.dark a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.resume-chip,
.tag,
.badge {
  background: color-mix(in hsl, var(--card) 70%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--muted);
  border-radius: 9999px;
  padding: .2rem .5rem;
  display: inline-block;
}

.dark table {
  border-color: var(--bd);
}

.dark th,
.dark td {
  border-color: var(--bd);
}

.dark thead th {
  background: color-mix(in hsl, var(--card) 60%, var(--bg));
  color: var(--ink);
}

.dark tbody tr:nth-child(2n) {
  background: color-mix(in hsl, var(--card) 85%, var(--bg));
}

.dark code {
  background: color-mix(in hsl, var(--card) 80%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
}

.dark pre {
  background: color-mix(in hsl, var(--card) 70%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
}

.dark blockquote {
  border-left: 3px solid var(--ring);
  color: var(--muted);
}

.dark .btn-primary {
  background: var(--brand);
  color: #fff;
  border: 1px solid color-mix(in hsl, var(--brand) 60%, #000);
}

.dark .btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--bd);
}

.dark .btn-primary:hover {
  filter: brightness(1.05);
}

.dark .btn-outline:hover {
  background: color-mix(in hsl, var(--brand) 10%, var(--bg));
}

.dark img,
.dark svg,
.dark .logo {
  filter: none !important;
  mix-blend-mode: normal !important;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.resume-section {
  padding: 16px;
  margin-block: 12px;
}

/* /projects/ slider enforcement (2025-09-06a) */
#mobile-menu.hidden {
  display: none
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--ink);
  transition: transform .2s ease
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(20px)
}

.dark .theme-toggle .switch__track {
  background: color-mix(in hsl, var(--brand) 25%, var(--bg));
  border-color: var(--bd)
}

.dark .theme-toggle .switch__thumb {
  background: #fff
}

/* === Dark-mode viewability polish (site-wide, non-destructive) === */

/* Base legibility */
.dark body {
  background: var(--bg);
  color: var(--ink);
}

.dark p,
.dark li {
  color: var(--ink);
}

.dark .muted,
.dark .subtitle,
.dark .lead {
  color: var(--muted);
}

/* Comfortable reading rhythm */
:root {
  --lh-body: 1.6;
  --space-paragraph: .65rem;
}

body {
  line-height: var(--lh-body);
}

p+p {
  margin-top: var(--space-paragraph);
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  margin-top: 1rem;
  margin-bottom: .5rem;
}

/* Links: higher contrast + clearer affordance */
.dark a {
  color: color-mix(in hsl, var(--brand) 85%, white 0%);
  text-decoration: none;
}

.dark a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Cards / content blocks (attach .card / .section / .resume-section where useful) */
.card,
.section,
.resume-section,
.resume-card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Dividers */
.dark hr {
  border-color: var(--bd);
  opacity: 1;
}

/* Lists */
.dark ul,
.dark ol {
  color: var(--ink);
  padding-left: 1.15rem;
}

.dark li::marker {
  color: var(--muted);
}

/* Tables */
.dark table {
  width: 100%;
  border-collapse: collapse;
  border-color: var(--bd);
}

.dark th,
.dark td {
  border-color: var(--bd);
}

.dark thead th {
  background: color-mix(in hsl, var(--card) 60%, var(--bg));
  color: var(--ink);
}

.dark tbody tr:nth-child(2n) {
  background: color-mix(in hsl, var(--card) 85%, var(--bg));
}

/* Code / pre / quotes */
.dark code {
  background: color-mix(in hsl, var(--card) 80%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 6px;
  padding: .1rem .3rem;
}

.dark pre {
  background: color-mix(in hsl, var(--card) 70%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 8px;
  padding: .75rem;
  overflow: auto;
}

.dark blockquote {
  color: var(--muted);
  border-left: 3px solid var(--ring);
  padding-left: .75rem;
  margin-left: 0;
}

/* Buttons */
.dark .btn-primary {
  background: var(--brand);
  color: #fff;
  border: 1px solid color-mix(in hsl, var(--brand) 60%, #000);
}

.dark .btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--bd);
}

.dark .btn-primary:hover {
  filter: brightness(1.05);
}

.dark .btn-outline:hover {
  background: color-mix(in hsl, var(--brand) 10%, var(--bg));
}

/* Images/logos should not invert */
.dark img,
.dark svg,
.dark .logo {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Mobile drawer visibility (used by theme.js) */
#mobile-menu.hidden {
  display: none;
}

/* Theme toggle visuals (shared desktop+mobile) */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block;
  transition: background .2s ease;
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--ink);
  transition: transform .2s ease;
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(20px);
}

.dark .theme-toggle .switch__track {
  background: color-mix(in hsl, var(--brand) 25%, var(--bg));
  border-color: var(--bd);
}

.dark .theme-toggle .switch__thumb {
  background: #fff;
}

/* Prefer higher contrast for users who ask for it */
@media (prefers-contrast: more) {
  .dark a {
    text-decoration: underline;
  }

  :focus-visible {
    outline-width: 3px;
  }
}

/* === Résumé dark-mode polish (scoped) === */
.dark body {
  background: var(--bg);
  color: var(--ink);
}

/* Headings / subheads */
.dark h1,
.dark h2,
.dark h3,
.dark h4 {
  color: var(--ink);
}

.dark .lead,
.dark .subtitle {
  color: var(--muted);
}

/* Section wrappers / cards (add .resume-section/.resume-card classes in your markup if not present) */
.resume-section,
.resume-card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-block: 12px;
}

/* Links (higher contrast in dark) */
.dark a {
  color: color-mix(in hsl, var(--brand) 85%, white 0%);
  text-decoration: none;
}

.dark a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Lists */
.dark ul,
.dark ol {
  color: var(--ink);
}

.dark li::marker {
  color: var(--muted);
}

/* Tables */
.dark table {
  border-color: var(--bd);
}

.dark th,
.dark td {
  border-color: var(--bd);
}

.dark thead th {
  background: color-mix(in hsl, var(--card) 60%, var(--bg));
  color: var(--ink);
}

.dark tbody tr:nth-child(2n) {
  background: color-mix(in hsl, var(--card) 85%, var(--bg));
}

/* Code / pre / quotes */
.dark code {
  background: color-mix(in hsl, var(--card) 80%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 6px;
  padding: .1rem .3rem;
}

.dark pre {
  background: color-mix(in hsl, var(--card) 70%, var(--bg));
  border: 1px solid var(--bd);
  color: var(--ink);
  border-radius: 8px;
  padding: .75rem;
  overflow: auto;
}

.dark blockquote {
  color: var(--muted);
  border-left: 3px solid var(--ring);
  padding-left: .75rem;
}

/* Buttons */
.dark .btn-primary {
  background: var(--brand);
  color: #fff;
  border: 1px solid color-mix(in hsl, var(--brand) 60%, #000);
}

.dark .btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--bd);
}

.dark .btn-primary:hover {
  filter: brightness(1.05);
}

.dark .btn-outline:hover {
  background: color-mix(in hsl, var(--brand) 10%, var(--bg));
}

/* Avoid accidental image inversion in dark */
.dark img,
.dark svg,
.dark .logo {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Ensure the header toggle looks correct */
#mobile-menu.hidden {
  display: none
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.theme-toggle .switch__track {
  width: 44px;
  height: 24px;
  border: 1px solid var(--bd);
  border-radius: 9999px;
  background: var(--chip);
  display: inline-block;
  transition: background .2s ease;
}

.theme-toggle .switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--ink);
  transition: transform .2s ease;
}

.theme-toggle[aria-pressed="true"] .switch__thumb {
  transform: translateX(20px)
}

.dark .theme-toggle .switch__track {
  background: color-mix(in hsl, var(--brand) 25%, var(--bg));
  border-color: var(--bd);
}

.dark .theme-toggle .switch__thumb {
  background: #fff;
}
