:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #dde2ea;
  --text: #0f1729;
  --muted: #4b5568;
  --accent: #2f54d6;
  --accent-soft: rgba(47, 84, 214, 0.1);
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 41, 0.06), 0 8px 24px rgba(15, 23, 41, 0.06);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 14px;
  --container: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e14;
    --surface: #121722;
    --surface-2: #1a2030;
    --border: #262e40;
    --text: #e8ebf2;
    --muted: #a3acbd;
    --accent: #8ea6ff;
    --accent-soft: rgba(142, 166, 255, 0.12);
    --on-accent: #0b0e14;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0e14;
  --surface: #121722;
  --surface-2: #1a2030;
  --border: #262e40;
  --text: #e8ebf2;
  --muted: #a3acbd;
  --accent: #8ea6ff;
  --accent-soft: rgba(142, 166, 255, 0.12);
  --on-accent: #0b0e14;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

.btn:hover,
.brand:hover,
.nav-links a:hover,
.card-link:hover,
.contact-list a:hover,
.back-link:hover,
.cs-next a:hover {
  text-decoration: none;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
}

h1 {
  font-size: clamp(2rem, 4.5vw, 3.25rem);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

h3 {
  font-size: 1.2rem;
}

p {
  margin: 0 0 1em;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.container {
  width: min(100% - 2.5rem, var(--container));
  margin-inline: auto;
}

.narrow {
  width: min(100% - 2.5rem, 760px);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  z-index: 100;
}

.skip-link:focus {
  top: 1rem;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand span {
  color: var(--accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 760px) {
  .nav-links {
    display: none;
  }
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.975rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-small {
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
}

/* Sections */
.section {
  padding-block: clamp(2rem, 4vw, 3rem);
}

.hero + .section {
  border-top: 1px solid var(--border);
  padding-top: clamp(1.5rem, 3vw, 2rem);
}

.section-alt {
  background: var(--surface);
  border-block: 1px solid var(--border);
}

.section-head {
  max-width: 680px;
  margin-bottom: 1.75rem;
}

.section-head p:last-child {
  margin-bottom: 0;
}

.section-head p {
  color: var(--muted);
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

/* Hero */
.hero {
  padding-block: clamp(2rem, 4vw, 3rem) clamp(1.5rem, 3vw, 2rem);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 3rem;
  align-items: center;
}

@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .hero-photo {
    order: -1;
    max-width: 220px;
  }
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.hero-lead {
  font-size: 1.2rem;
  color: var(--muted);
  max-width: 600px;
  margin-bottom: 1.5rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-photo img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Metrics */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 2.25rem;
  padding: 0;
  list-style: none;
}

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

.metric {
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.metric strong {
  display: block;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

@media (max-width: 480px) {
  .metric strong {
    font-size: 1.45rem;
  }
}

.metric span {
  color: var(--muted);
  font-size: 0.925rem;
  line-height: 1.45;
  display: block;
}

/* Expertise */
.expertise {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

@media (max-width: 960px) {
  .expertise {
    grid-template-columns: 1fr;
  }
}

.expertise-card {
  display: flex;
  flex-direction: column;
  padding: 1.75rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.expertise-card > p {
  color: var(--muted);
}

.expertise-card ul {
  margin: 0 0 1.25rem;
  padding-left: 1.1rem;
}

.expertise-card li + li {
  margin-top: 0.35rem;
}

.expertise-label {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 1rem;
}

.expertise-projects {
  margin: auto 0 0;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
  font-size: 0.9rem;
}

.expertise-projects::before {
  content: "Projects: ";
  font-weight: 600;
  color: var(--text);
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

@media (max-width: 760px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.75rem;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card p {
  color: var(--muted);
}

.card-link {
  color: var(--text);
  text-decoration: none;
}

.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.card-outcome {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
  font-weight: 600;
  color: var(--text) !important;
  font-size: 0.95rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.tags li {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.project {
  padding: 1.25rem 1.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
}

.project h3 {
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.project p {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.subheading {
  margin-top: 2.25rem;
  font-size: 1.25rem;
}

/* Timeline */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--border);
}

.timeline-item {
  position: relative;
  padding: 0 0 1.75rem 2rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 0.45rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}

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

.timeline-head h3 {
  margin-bottom: 0.2rem;
}

.timeline-meta {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.timeline-company {
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.timeline ul {
  margin: 0;
  padding-left: 1.1rem;
}

.timeline li + li {
  margin-top: 0.4rem;
}

.earlier {
  list-style: none;
  padding: 0;
  margin: 0;
}

.earlier li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

/* Skills */
.skills {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.skill-group {
  padding: 1.4rem;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}

.skill-group h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.skill-group .tags {
  margin: 0;
}

/* Callout */
.callout {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.callout p {
  margin: 0;
  color: var(--muted);
}

.callout h3 {
  margin-bottom: 0.35rem;
}

@media (max-width: 760px) {
  .callout {
    grid-template-columns: 1fr;
  }
}

/* Contact */
.contact-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
}

.contact-list a {
  display: block;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  word-break: break-word;
}

.contact-list a:hover {
  border-color: var(--accent);
}

.contact-list small {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

/* Footer */
.site-footer {
  padding-block: 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer a {
  color: var(--muted);
}

/* Case study pages */
.cs-hero {
  padding-block: clamp(2rem, 4vw, 3rem) 1.5rem;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--text);
}

.cs-lead {
  font-size: 1.2rem;
  color: var(--muted);
}

.cs-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 2rem 0 0;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.cs-meta dt {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.cs-meta dd {
  margin: 0.2rem 0 0;
  font-weight: 500;
}

.cs-body {
  padding-bottom: 3rem;
}

.cs-body h2 {
  font-size: 1.5rem;
  margin-top: 2rem;
}

.cs-body ul {
  padding-left: 1.2rem;
}

.cs-body li + li {
  margin-top: 0.5rem;
}

.cs-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0 !important;
}

.cs-results li {
  margin: 0 !important;
}

.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  list-style: none;
  padding: 1.25rem !important;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.flow li {
  margin: 0 !important;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flow li:not(:last-child)::after {
  content: "→";
  color: var(--accent);
  font-weight: 700;
}

.flow span {
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 500;
}

.flow-caption {
  margin-top: -0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

pre {
  overflow-x: auto;
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  line-height: 1.6;
}

.note {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.925rem;
}

.cs-next {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.cs-next a {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.cs-next a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Motion */
.site-header {
  transition: box-shadow 0.25s ease;
}

.site-header.is-scrolled {
  box-shadow: 0 6px 24px rgba(15, 23, 41, 0.08);
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(18px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .hero-grid > *,
  .hero .metric,
  .cs-hero .narrow > * {
    animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .hero-grid > :nth-child(2) {
    animation-delay: 0.12s;
  }

  .hero .metric:nth-child(1) { animation-delay: 0.2s; }
  .hero .metric:nth-child(2) { animation-delay: 0.27s; }
  .hero .metric:nth-child(3) { animation-delay: 0.34s; }
  .hero .metric:nth-child(4) { animation-delay: 0.41s; }

  [data-reveal] {
    opacity: 0;
  }

  /* "backwards" (not "both") so hover transforms still apply once the reveal ends. */
  [data-reveal].is-visible {
    opacity: 1;
    animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) var(--reveal-delay, 0s) backwards;
  }
}

.not-found {
  min-height: 60vh;
  display: grid;
  place-content: center;
  text-align: center;
}
