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

:root {
  color-scheme: dark;
  --bg-body: #000000;
  --text-body: #ffffff;
  --link: #a8c8ff;
  --link-hover: #d4e4ff;
  --nav-bg-1: #000000;
  --nav-bg-2: #0a0a0a;
  --border-subtle: rgba(255, 255, 255, 0.12);
  --nav-shadow: 0 10px 30px rgba(0, 0, 0, 0.85);
  --nav-link: #ffffff;
  --underline-2: #a3a3a3;
  --nav-icon-hover: #c8daff;
  --avatar-bg: #141414;
  --avatar-border: rgba(255, 255, 255, 0.18);
  --tagline: #c8c8c8;
  --heading: #ffffff;
  --timeline-1: #e5e5e5;
  --timeline-2: #6b6b6b;
  --timeline-dot: #ffffff;
  --timeline-ring: #000000;
  --muted: #b0b0b0;
  --meta: #c0c0c0;
  --summary: #f0f0f0;
  --card-bg: #0a0a0a;
  --card-border: rgba(255, 255, 255, 0.12);
  --card-border-project: rgba(255, 255, 255, 0.14);
  --tag-bg: rgba(255, 255, 255, 0.08);
  --tag-border: rgba(255, 255, 255, 0.22);
  --project-hover-border: rgba(255, 255, 255, 0.35);
  --project-hover-shadow: 0 4px 24px rgba(0, 0, 0, 0.75);
  --project-link-hover-bg: rgba(255, 255, 255, 0.1);
  --focus-ring: rgba(255, 255, 255, 0.55);
  --modal-backdrop: rgba(0, 0, 0, 0.88);
  --modal-content-bg: #0d0d0d;
  --modal-content-border: rgba(255, 255, 255, 0.14);
  --modal-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  --modal-desc: #e8e8e8;
  --modal-h3: #f2f2f2;
  --modal-h4: #e0e0e0;
  --modal-em: #b8b8b8;
  --modal-pre-bg: rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-body: #f4f4f6;
  --text-body: #111111;
  --link: #1d4ed8;
  --link-hover: #2563eb;
  --nav-bg-1: #ffffff;
  --nav-bg-2: #f0f0f3;
  --border-subtle: rgba(0, 0, 0, 0.1);
  --nav-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --nav-link: #111111;
  --underline-2: #737373;
  --nav-icon-hover: #1d4ed8;
  --avatar-bg: #e8e8ec;
  --avatar-border: rgba(0, 0, 0, 0.12);
  --tagline: #4a4a4f;
  --heading: #0a0a0a;
  --timeline-1: #9ca3af;
  --timeline-2: #d1d5db;
  --timeline-dot: #111111;
  --timeline-ring: #f4f4f6;
  --muted: #64646c;
  --meta: #52525b;
  --summary: #1f1f24;
  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.1);
  --card-border-project: rgba(0, 0, 0, 0.12);
  --tag-bg: rgba(0, 0, 0, 0.05);
  --tag-border: rgba(0, 0, 0, 0.12);
  --project-hover-border: rgba(0, 0, 0, 0.22);
  --project-hover-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  --project-link-hover-bg: rgba(0, 0, 0, 0.06);
  --focus-ring: rgba(29, 78, 216, 0.45);
  --modal-backdrop: rgba(0, 0, 0, 0.45);
  --modal-content-bg: #ffffff;
  --modal-content-border: rgba(0, 0, 0, 0.12);
  --modal-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  --modal-desc: #3f3f46;
  --modal-h3: #18181b;
  --modal-h4: #27272a;
  --modal-em: #71717a;
  --modal-pre-bg: rgba(0, 0, 0, 0.06);
}

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Roboto", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: var(--bg-body);
  color: var(--text-body);
}

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

a:hover {
  text-decoration: underline;
}

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2.5rem;
  margin: 0 0 1rem;
  font-size: 1rem;
  background: linear-gradient(90deg, var(--nav-bg-1), var(--nav-bg-2));
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--nav-shadow);
  backdrop-filter: blur(10px);
}

.page {
  max-width: 100%;
  margin: 5.5rem 0 3rem;
  padding: 0 1.5rem;
}

.top-nav-links {
  display: flex;
  gap: 2.2rem;
}

.top-nav a {
  position: relative;
  color: var(--nav-link);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.9rem;
  font-weight: bold;
}

.top-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.35rem;
  width: 0;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--nav-link), var(--underline-2));
  opacity: 0;
  transition: width 0.18s ease-out, opacity 0.18s ease-out;
}

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

.top-nav a:hover::after {
  width: 100%;
  opacity: 1;
}

.theme-toggle .material-symbols-outlined {
  font-size: 1em;
  line-height: 1;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

.top-nav-icons {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.top-nav-icons .nav-icon {
  color: var(--nav-link);
  font-size: 2.0rem;
  text-transform: none;
  letter-spacing: 0;
}

.top-nav-icons .nav-icon::after {
  display: none;
}

.top-nav-icons .nav-icon:hover {
  color: var(--nav-icon-hover);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.15rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--nav-link);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
  color: var(--nav-icon-hover);
  background-color: var(--project-link-hover-bg);
}

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

.intro {
  margin-bottom: 1.5rem;
  padding: 1.5rem 0 0;
  text-align: center;
}

.intro-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.intro-avatar-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--avatar-bg);
  border: 2px solid var(--avatar-border);
  object-fit: cover;
}

.intro h1 {
  margin: 0 0 0.25rem;
  font-size: 3rem;
}

.tagline {
  margin: 0 auto;
  max-width: min(56rem, 94%);
  color: var(--tagline);
}

section {
  margin: 2.5rem 0 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  scroll-margin-top: 72px;
}

section:first-of-type {
  margin-top: 1.5rem;
}

section:last-of-type {
  margin-bottom: 0;
}

.section-title {
  font-size: 1.6rem;
  margin: 0 0 0.8rem;
  color: var(--heading);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
}

#about {
  scroll-margin-top: 72px;
}

h3 {
  font-size: 1.05rem;
  margin: 0.6rem 0 0.25rem;
}

/* Timeline */
.timeline {
  position: relative;
  max-width: 1180px;
  margin: 1.5rem auto 0;
  padding: 0 1rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--timeline-1), var(--timeline-2));
  transform: translateX(-50%);
}

.timeline-item {
  position: relative;
  display: flex;
  width: 100%;
  margin-bottom: 2rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 1.5rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--timeline-dot);
  box-shadow: 0 0 0 4px var(--timeline-ring);
  transform: translate(-50%, 0);
  z-index: 1;
}

.timeline-date {
  position: absolute;
  top: 1.5rem;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  z-index: 1;
}

.timeline-left .timeline-date {
  left: calc(50% + 1rem);
}

.timeline-right .timeline-date {
  right: calc(50% + 1rem);
}

.timeline-left {
  justify-content: flex-start;
}

.timeline-right {
  justify-content: flex-end;
}

article.experience-card {
  width: calc(50% - 1.25rem);
  max-width: 580px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 1.25rem;
  row-gap: 0.5rem;
  padding: 1.0rem 1.4rem;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
}

.experience-card-incoming {
  border-style: dashed;
  opacity: 0.9;
}

.experience-meta {
  font-size: 0.85rem;
  color: var(--meta);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
}

.experience-location {
  font-size: 0.75rem;
  margin: 0.15rem 0 0.25rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.experience-image {
  width: 100%;
  max-width: 120px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  object-fit: cover;
}

.experience-main {
  font-size: 0.95rem;
}

.experience-summary {
  margin: 0.2rem 0 0.4rem;
  color: var(--summary);
}

.experience-main ul {
  margin-top: 0.35rem;
}

.experience-tags,
.project-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0;
  margin: 0.7rem 0 0;
}

.experience-tags li,
.project-tags li {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
}

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

ul:not(.experience-tags):not(.project-tags):not(.modal-tags) li + li {
  margin-top: 0.25rem;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.project-card {
  padding: 1.1rem 1.2rem;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border-project);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.project-card:hover,
.project-card:focus {
  border-color: var(--project-hover-border);
  box-shadow: var(--project-hover-shadow);
  outline: none;
}

.project-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.35rem;
}

.project-card-header h3 {
  margin: 0;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
}

.project-card-links {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
  margin: -0.15rem 0;
}

.project-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--meta);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.15rem;
  border-radius: 8px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.project-link:hover {
  color: var(--heading);
  background-color: var(--project-link-hover-bg);
}

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

.project-card .project-tags {
  margin-top: 0.5rem;
}

.project-dates {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.4rem;
  letter-spacing: 0.04em;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  max-width: 800px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.75rem 2rem;
  border-radius: 16px;
  background: var(--modal-content-bg);
  border: 1px solid var(--modal-content-border);
  box-shadow: var(--modal-shadow);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.35rem;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.2s ease, background 0.2s ease;
}

.modal-close:hover {
  color: var(--heading);
  background: var(--project-link-hover-bg);
}

.modal-title {
  margin: 0 2rem 0.75rem 0;
  font-size: 1.35rem;
}

.modal-description {
  margin: 0 0 1rem;
  color: var(--modal-desc);
  line-height: 1.6;
}

.modal-description h2 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.35;
}

.modal-description h2:first-child {
  margin-top: 0;
}

.modal-description h3 {
  margin: 1rem 0 0.4rem;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--modal-h3);
  line-height: 1.35;
}

.modal-description h4 {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--modal-h4);
}

.modal-description > *:first-child {
  margin-top: 0;
}

.modal-description > *:last-child {
  margin-bottom: 0;
}

.modal-description p {
  margin: 0 0 0.75rem;
}

.modal-description ul,
.modal-description ol {
  margin: 0 0 0.75rem;
  padding-left: 1.35rem;
}

.modal-description li {
  margin: 0.25rem 0;
}

.modal-description strong {
  color: var(--heading);
  font-weight: 600;
}

.modal-description em {
  color: var(--modal-em);
}

.modal-description code {
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--tag-bg);
}

.modal-description pre {
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--modal-pre-bg);
  font-size: 0.9em;
}

.modal-description pre code {
  padding: 0;
  background: none;
}

.modal-description a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.modal-description a:hover {
  color: var(--link-hover);
}

.modal-description hr {
  margin: 1rem 0;
  border: none;
  border-top: 1px solid var(--border-subtle);
}

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

.modal-tags li {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
}

.footer {
  margin-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
}

@media (max-width: 900px) {
  .page {
    padding: 0 1.25rem;
  }

  .timeline {
    padding: 0 0.5rem;
  }

  .timeline::before {
    left: 1rem;
    transform: none;
  }

  .timeline-item {
    justify-content: flex-end;
    padding-left: 2.5rem;
  }

  .timeline-item::before {
    left: 1rem;
    transform: translate(-50%, 0);
  }

  .timeline-date {
    left: calc(1rem + 1rem) !important;
    right: auto !important;
  }

  article.experience-card {
    width: 100%;
    max-width: none;
  }

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

@media (max-width: 640px) {
  .top-nav {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }

  .top-nav-links {
    gap: 1rem;
  }

  .top-nav a {
    font-size: 0.8rem;
  }

  .top-nav-icons {
    gap: 0.5rem;
  }

  .top-nav-icons .nav-icon {
    font-size: 1.25rem;
  }

  .theme-toggle {
    font-size: 1.25rem;
  }

  .page {
    margin: 2.25rem 0 2.5rem;
    padding: 0 1rem;
  }

  .intro {
    padding-top: 2rem;
  }

  .intro h1 {
    font-size: 1.7rem;
  }

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

  /* Timeline: stack date above card, more breathing room */
  .timeline {
    padding: 0;
  }

  .timeline-item {
    flex-direction: column;
    align-items: stretch;
    padding-left: 2rem;
    padding-top: 1.5rem;
    margin-bottom: 2.5rem;
  }

  .timeline-item::before {
    top: 0.75rem;
  }

  .timeline-date {
    position: absolute !important;
    top: 0.75rem !important;
    transform: translateY(-50%) !important;
    left: calc(1rem + 1rem) !important;
    right: auto !important;
    margin-bottom: 0;
    padding-left: 0.5rem;
  }

  article.experience-card {
    grid-template-columns: 1fr;
    padding: 1rem 1rem;
    gap: 0.75rem;
  }

  .experience-meta {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  .experience-image {
    max-width: 56px;
    flex-shrink: 0;
  }

  .experience-summary {
    font-size: 0.9rem;
  }

  .experience-tags {
    margin-top: 0.5rem;
  }
}

