:root {
  --navy: #1f4e79;
  --navy-dark: #163a5c;
  --navy-light: #e8f0f8;
  --ink: #1a1a1a;
  --muted: #5a6570;
  --border: #e2e6ea;
  --bg: #ffffff;
  --bg-alt: #f7f9fb;
  --card-bg: #ffffff;
  --radius: 10px;
  --max-width: 920px;
  --font:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

html[data-theme="dark"] {
  --navy: #5b9bd5;
  --navy-dark: #7fb2e0;
  --navy-light: #16324a;
  --ink: #eef2f6;
  --muted: #9aa7b4;
  --border: #2a3542;
  --bg: #0f1620;
  --bg-alt: #131b26;
  --card-bg: #161f2b;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition:
    background 0.25s ease,
    color 0.25s ease;
}

/* Scroll progress bar */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--navy);
  z-index: 100;
  transition: width 0.1s linear;
}

/* Reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.55s ease,
    transform 0.55s ease;
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  html {
    scroll-behavior: auto;
  }
}

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

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header / Nav */
header.site-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  opacity: 0.96;
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  transition: background 0.25s ease;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--navy);
  letter-spacing: 0.2px;
}

nav.site-nav ul {
  list-style: none;
  display: flex;
  gap: 28px;
  margin: 0;
  padding: 0;
}

nav.site-nav a {
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  position: relative;
  padding-bottom: 3px;
}

nav.site-nav a:hover {
  color: var(--navy);
  text-decoration: none;
}

nav.site-nav a.active {
  color: var(--navy);
}
nav.site-nav a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  background: var(--navy);
  border-radius: 2px;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--navy);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}
.theme-toggle:hover {
  border-color: var(--navy);
}

/* Hero */
.hero {
  padding: 72px 0 56px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--navy-light) 0%, var(--bg) 100%);
}

.hero .eyebrow {
  color: var(--navy);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.hero h1 {
  font-size: 40px;
  margin: 0 0 8px;
  color: var(--ink);
}

.hero .role {
  font-size: 20px;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 18px;
}

.hero p.lead {
  font-size: 17px;
  color: var(--muted);
  max-width: 640px;
  margin-bottom: 26px;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover {
  background: var(--navy-dark);
  text-decoration: none;
}

.btn-outline {
  border-color: var(--navy);
  color: var(--navy);
  background: transparent;
}
.btn-outline:hover {
  background: var(--navy-light);
  text-decoration: none;
}

/* Stats strip */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 18px;
  padding: 36px 0;
  border-bottom: 1px solid var(--border);
}
.stat {
  text-align: center;
}
.stat .num {
  font-size: 32px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
.stat .label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Sections */
section {
  padding: 56px 0;
}
section.alt {
  background: var(--bg-alt);
}

.section-head {
  margin-bottom: 32px;
}
.section-head .eyebrow {
  color: var(--navy);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.section-head h2 {
  font-size: 28px;
  margin: 6px 0 0;
}

/* Experience */
.timeline {
  position: relative;
  padding-left: 28px;
  border-left: 2px solid var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 34px;
  display: block;
}
.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -34px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--navy);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--navy);
}

.timeline-item h3 {
  margin: 0 0 2px;
  font-size: 18px;
  display: inline;
}
.timeline-item .meta {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 10px;
}
.timeline-item .meta .company {
  color: var(--navy);
  font-weight: 600;
}

.timeline-item ul {
  margin: 0;
  padding-left: 20px;
}
.timeline-item li {
  margin-bottom: 6px;
  font-size: 15px;
}

.timeline-item .stack {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* Collapsible timeline entries */
.timeline-item summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.timeline-item summary::-webkit-details-marker {
  display: none;
}
.timeline-item summary::after {
  content: "+";
  margin-left: auto;
  color: var(--navy);
  font-size: 18px;
  font-weight: 700;
  transition: transform 0.2s ease;
}
.timeline-item[open] summary::after {
  content: "\2212";
}
.timeline-item summary:hover h3 {
  text-decoration: underline;
}
.timeline-item .details-body {
  padding-top: 12px;
}

/* Projects */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.project-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--card-bg);
}

.project-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}
.project-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
}

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

.skill-cat h3 {
  font-size: 15px;
  color: var(--navy);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: var(--navy-light);
  color: var(--navy-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
}

/* Blog */
.post-grid {
  display: grid;
  gap: 18px;
}

.post-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: block;
  color: var(--ink);
  background: var(--card-bg);
}
.post-card:hover {
  border-color: var(--navy);
  text-decoration: none;
}
.post-card .date {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.post-card h3 {
  margin: 0 0 8px;
  font-size: 19px;
  color: var(--ink);
}
.post-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
}

.draft-note {
  background: #fff6e5;
  border: 1px solid #f0d9a8;
  color: #7a5c17;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 24px;
}

article.post h1 {
  font-size: 32px;
  margin-bottom: 6px;
}
article.post .meta {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 30px;
}
article.post h2 {
  font-size: 21px;
  margin-top: 34px;
}
article.post p {
  font-size: 16px;
  margin-bottom: 16px;
}
article.post ul {
  font-size: 16px;
}

/* Contact */
.contact-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.contact-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  flex: 1;
  min-width: 220px;
  background: var(--card-bg);
}
.contact-card .label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.contact-card a {
  font-size: 16px;
  font-weight: 600;
}
.contact-card .row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.copy-btn {
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    color 0.2s ease;
}
.copy-btn:hover {
  border-color: var(--navy);
  color: var(--navy);
}
.copy-btn.copied {
  border-color: var(--navy);
  color: var(--navy);
}

/* Back to top */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--navy);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  z-index: 60;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Footer */
footer.site-footer {
  border-top: 1px solid var(--border);
  padding: 26px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* Responsive */
@media (max-width: 760px) {
  nav.site-nav {
    display: none;
  }
  nav.site-nav.open {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  nav.site-nav.open ul {
    flex-direction: column;
    padding: 14px 24px;
    gap: 14px;
  }
  .nav-toggle {
    display: block;
  }
  .hero h1 {
    font-size: 30px;
  }
  .hero .role {
    font-size: 17px;
  }
  section {
    padding: 40px 0;
  }
}

/* ===== Redesign: icons and personal mark ===== */
body.home {
  --max-width: 1040px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: var(--navy-light);
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brand-mark.sm {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
}
.brand-link:hover {
  text-decoration: none;
}

/* Header order: brand | nav | theme toggle (far right) */
nav.site-nav {
  order: 2;
  margin-left: auto;
}
.nav-actions {
  order: 3;
  margin-left: 22px;
}

.theme-toggle svg {
  display: block;
}

.hero-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 40px;
}
.hero-text {
  flex: 999 1 480px;
  min-width: 0;
}
.hero-mark {
  flex: 1 1 160px;
  max-width: 180px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 28px;
  background: var(--navy-light);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-mark svg {
  width: 58%;
  height: 58%;
}

.icon-tile {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: var(--radius);
  background: var(--navy-light);
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-tile.sm {
  width: 44px;
  height: 44px;
}

.expertise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}
.expertise-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.expertise-card .icon-tile {
  width: 52px;
  height: 52px;
}
.expertise-card h3 {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.35;
}
.expertise-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.timeline-item summary {
  align-items: center;
  flex-wrap: wrap;
}
.role-icons {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
}
.timeline-item summary:has(.role-icons)::after {
  margin-left: 4px;
}
.icon-chip {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--navy-light);
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.project-card.has-icon {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.project-card.has-icon > div {
  min-width: 0;
}
#projects .project-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.contact-card.has-icon {
  display: flex;
  gap: 14px;
  align-items: center;
}
.contact-card.has-icon > div {
  min-width: 0;
}
.contact-card.has-icon .row {
  flex-wrap: wrap;
  gap: 6px 10px;
}
.contact-card.has-icon a {
  overflow-wrap: anywhere;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

@media (max-width: 760px) {
  .hero-mark {
    display: none;
  }
  #projects .project-grid {
    grid-template-columns: 1fr;
  }
}
