@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700&display=swap');

:root {
  --bg: #f8f8f6;
  --surface: #ffffff;
  --text: #171717;
  --muted: #686868;
  --border: #deded9;
  --soft: #efefeb;
  --accent: #171717;
  --shadow: 0 18px 50px rgba(0,0,0,.08);
  --max: 1120px;
}

html[data-theme="dark"] {
  --bg: #111110;
  --surface: #181817;
  --text: #f3f3ef;
  --muted: #aaa9a3;
  --border: #343431;
  --soft: #22221f;
  --accent: #f3f3ef;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  line-height: 1.65;
  transition: background .2s ease, color .2s ease;
}

body.modal-open { overflow: hidden; }

a {
  color: inherit;
  text-decoration: none;
}

button, a { -webkit-tap-highlight-color: transparent; }

button { font: inherit; }

.container {
  width: min(calc(100% - 48px), var(--max));
  margin-inline: auto;
}

.narrow { max-width: 820px; }

.section {
  padding: 112px 0;
}

.section-border { border-top: 1px solid var(--border); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.brand {
  font-family: "Manrope", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  white-space: nowrap;
}

.nav-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 14px;
  color: var(--muted);
}

.nav-menu a:hover,
.nav-menu a:focus-visible { color: var(--text); }

.theme-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  display: none;
  min-width: 110px;
  padding: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: 10px;
}

.theme-menu.is-open { display: grid; }

.theme-menu button {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.theme-menu button:hover,
.theme-menu button:focus-visible { background: var(--soft); }

.menu-toggle { display: none; }

.hero { padding: 128px 0 116px; }

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 100px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 18px;
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--muted);
}

h1, h2, h3 {
  font-family: "Manrope", sans-serif;
  line-height: 1.15;
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(44px, 6vw, 74px);
  letter-spacing: -.045em;
}

.hero h2 {
  margin-bottom: 24px;
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 500;
  color: var(--muted);
}

.hero-intro {
  max-width: 650px;
  margin: 0;
  font-size: 18px;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 34px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

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

.button-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

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

.text-link,
.text-button {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.text-link { padding: 8px 4px; }

.text-button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

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

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

.profile-frame {
  width: 320px;
  height: 320px;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--soft);
  border-radius: 50%;
  overflow: hidden;
}

.profile-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  transition: opacity .22s ease;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-frame img.profile-fade { opacity: 0; }

.profile-caption {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.section-heading { margin-bottom: 48px; }

.section-heading h2,
.contact-section h2 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: -.035em;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  align-items: end;
}

.section-note {
  max-width: 350px;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 19px;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 42px 48px;
}

.skill-group h3 {
  margin-bottom: 16px;
  font-size: 15px;
}

.skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.skill-tag,
.modal-tags span {
  display: inline-block;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}

.experience-list {
  border-top: 1px solid var(--border);
}

.experience-item {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 50px;
  padding: 34px 0;
  border-bottom: 1px solid var(--border);
}

.experience-meta {
  color: var(--muted);
  font-size: 13px;
}

.experience-body h3 {
  margin-bottom: 5px;
  font-size: 22px;
}

.company {
  margin: 0 0 13px;
  color: var(--muted);
  font-weight: 500;
}

.summary {
  margin: 0 0 18px;
  max-width: 720px;
  color: var(--muted);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
}

.project-card {
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: transform .15s ease, box-shadow .15s ease;
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.project-card > img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
}

.project-content { padding: 25px; }

.project-content h3 {
  margin-bottom: 8px;
  font-size: 22px;
}

.project-content p {
  margin: 0 0 17px;
  color: var(--muted);
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 22px;
}

.project-tags span {
  font-size: 11px;
  color: var(--muted);
}

.project-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 17px;
  font-size: 13px;
}

.project-actions a:hover { text-decoration: underline; }

.education-list {
  border-top: 1px solid var(--border);
}

.education-item {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 50px;
  padding: 34px 0;
  border-bottom: 1px solid var(--border);
}

.education-year { color: var(--muted); font-size: 13px; }

.education-content h3 {
  margin-bottom: 6px;
  font-size: 21px;
}

.education-content p { margin: 4px 0; color: var(--muted); }
.education-content .score { color: var(--text); font-weight: 600; }

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

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 80px;
  align-items: end;
}

.contact-section .lead {
  max-width: 650px;
  margin-top: 22px;
}

.contact-links {
  display: grid;
  gap: 10px;
  font-weight: 600;
}

.contact-links a {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}

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

.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--muted);
  font-size: 12px;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.modal.is-open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}

.modal-dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  padding: 42px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover { color: var(--text); }

.modal-header h2 {
  margin-bottom: 8px;
  font-size: 38px;
  letter-spacing: -.035em;
}

.modal-header p { color: var(--muted); }
.modal-company { margin: 0; }

.modal-sections {
  display: grid;
  gap: 28px;
  margin-top: 34px;
}

.modal-sections section { border-top: 1px solid var(--border); padding-top: 22px; }

.modal-sections h3 {
  margin-bottom: 11px;
  font-size: 14px;
}

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

.modal-sections ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.modal-sections li + li { margin-top: 7px; }

.modal-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.project-modal-image {
  margin: -42px -42px 34px;
}

.project-modal-image img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 8;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
}

.gallery-section { padding-bottom: 6px; }

.gallery {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 10px;
  align-items: center;
}

.gallery img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: var(--soft);
  border: 1px solid var(--border);
}

.gallery-prev,
.gallery-next {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.gallery-counter {
  text-align: center;
  font-size: 12px;
  margin-top: 8px !important;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 34px;
}

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

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

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

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

@media (max-width: 850px) {
  .container { width: min(calc(100% - 34px), var(--max)); }
  .navbar { min-height: 64px; }
  .menu-toggle {
    display: grid;
    width: 40px;
    height: 40px;
    place-content: center;
    gap: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    border-radius: 7px;
  }
  .menu-toggle span {
    width: 17px;
    height: 1px;
    background: var(--text);
  }
  .nav-menu {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    display: none;
    padding: 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
  }
  .nav-menu.is-open { display: flex; }
  .nav-menu a { padding: 10px 8px; }
  .theme-button { margin-top: 7px; text-align: left; }
  .theme-menu {
    position: static;
    margin-top: 4px;
    box-shadow: none;
  }

  .hero { padding: 82px 0 80px; }
  .hero-grid { grid-template-columns: 1fr; gap: 55px; }
  .profile-wrap { order: -1; }
  .profile-frame { width: min(280px, 78vw); height: 330px; }

  .section { padding: 82px 0; }
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
  .projects-grid { grid-template-columns: 1fr; }
  .section-heading-row { display: block; }
  .section-note { margin-top: 15px; }
  .contact-grid { grid-template-columns: 1fr; gap: 40px; }
}

@media (max-width: 560px) {
  .skills-grid { grid-template-columns: 1fr; gap: 30px; }
  .experience-item,
  .education-item { grid-template-columns: 1fr; gap: 10px; }
  .modal { padding: 10px; }
  .modal-dialog { padding: 30px 20px 24px; max-height: 94vh; }
  .project-modal-image { margin: -30px -20px 25px; }
  .modal-header h2 { font-size: 30px; }
  .hero-intro, .lead { font-size: 17px; }
  .footer-inner { flex-direction: column; }
}

.theme-icon {
  margin-right: 8px;
  position: relative;
  top: -1px;
}
