*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d0d0d;
  --surface: #141414;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #a0a0a0;
  --ph-a: #202020;
  --ph-b: #1a1a1a;
  --img-gap: 3px;
  --highlight: rgb(0, 255, 175);
  --font-heading: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html {
  scroll-behavior: smooth;
  zoom: 0.9;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ── Header / Intro ──────────────────────────────────────── */

header {
  display: flex;
  gap: 0;
  padding: 2rem 0 2rem;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
}

.header-left {
  flex: 3;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-right: 2rem;
  border-right: 1px solid var(--border);
}

.profile-intro {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.profile-pic {
  width: 150px;
  height: 150px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--ph-a);
  border: 2px solid var(--border);
  overflow: hidden;
}

.profile-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-text {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.social-links {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}


.header-left h1 {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.2;
  font-family: var(--font-heading);
}

.name-highlight {
  color: white;
}

.location {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.pin-icon {
  width: 14px;
  height: 14px;
  fill: var(--highlight);
  flex-shrink: 0;
}

.bio {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.highlight {
  color: var(--highlight);
}

.social-links {
  display: flex;
  gap: 0.5rem;
}

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: white;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.social-btn:hover {
  color: var(--highlight);
  border-color: var(--highlight);
}

.social-btn svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

/* Header right — tech stack */

.header-right {
  flex: 2;
  padding-top: 0.25rem;
  padding-left: 2rem;
}

.stack-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: white;
  margin-bottom: 0.9rem;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* shared tech badge */
.tech-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  font-size: 0.85rem;
  color: var(--text);
}

.tag-icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 1.1rem;
}

.tag-icon img {
  width: 1.3rem;
  height: 1.3rem;
  display: block;
  object-fit: contain;
}

.tag-icon img[src*="websocket"] {
  filter: invert(1);
}

.tag-icon--text {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.tag-label {
  padding: 0 0.65rem;
  line-height: 30px;
  font-family: var(--font-heading);
}

.tech-tags .tech-tag {
  background: var(--surface);
}

/* ── Projects Section ────────────────────────────────────── */

#projects {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1rem 0 2rem;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: white;
  margin-bottom: -0.5rem;
  font-family: var(--font-heading);
}

/* ── Project Card ────────────────────────────────────────── */

.project-card {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

/* Odd-positioned children (cards 2, 4…) swap images to the left */
.project-card:nth-child(odd) {
  flex-direction: row-reverse;
}

.project-info {
  flex: 1;
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  justify-content: flex-start;
  min-width: 0;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.project-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: white;
  font-family: var(--font-heading);
}

.project-desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.75;
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
}

.project-tech .tech-tag {
  background: var(--bg);
  font-size: 0.85rem;
  color: var(--text);
}

.project-tech .tag-icon {
  width: 30px;
  height: 30px;
}

.project-tech .tag-label {
  line-height: 30px;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: white;
  text-decoration: none;
  font-size: 1rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s;
  font-family: var(--font-heading);
}

.github-link:hover {
  color: var(--highlight);
}

.github-link:hover .gh-icon-box {
  border-color: var(--highlight);
}

.gh-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.github-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ── Image Area ──────────────────────────────────────────── */

.project-images {
  flex: 1;
  display: grid;
  gap: var(--img-gap);
  min-height: 380px;
  min-width: 0;
}

/* Placeholder tiles */
.img-ph {
  min-height: 0;
  min-width: 0;
}

.img-ph img,
.img-ph video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.img-ph:nth-child(odd)  { background: var(--ph-a); }
.img-ph:nth-child(even) { background: var(--ph-b); }

/* ── Image Layout Variants ───────────────────────────────── */

/* 2×2 grid — top row 1:1, bottom row 16:9 */
.layout-2x2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 16fr 9fr;
  aspect-ratio: 32 / 25;
  align-self: center;
  min-height: 0;
}

.layout-2x2 .img-ph img,
.layout-2x2 .img-ph video {
  object-fit: cover;
}

/* 1 tall portrait (9:16) left + 2 landscape (16:9) stacked right */
/* 81:128 cols + 209:144 panel ratio → cells land exactly on 9:16 and 16:9 */
/* gap: 0 is required — any gap breaks the aspect-ratio math */
.layout-1v-2h {
  grid-template-columns: 81fr 128fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 209 / 144;
  align-self: center;
  min-height: 0;
}
.layout-1v-2h .img-ph:first-child {
  grid-row: 1 / 3;
}

/* 2 portrait images side by side */
.layout-2v {
  grid-template-columns: 1fr 1fr;
}

/* 2 landscape images stacked */
.layout-2h {
  grid-template-columns: 1fr;
  flex: 0 0 40%;
  min-height: 0;
}

.layout-2h .img-ph img {
  height: auto;
}

/* 3 landscape images stacked */
.layout-3h {
  grid-template-rows: 1fr 1fr 1fr;
}

/* ── Contact Section ─────────────────────────────────────── */

#contact {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.2rem 0 1rem;
  border-top: 1px solid var(--border);
}

.contact-row {
  display: grid;
  grid-template-columns: 45% 1fr;
  column-gap: 2rem;
  row-gap: 0.9rem;
  align-items: start;
}

.contact-row .section-title,
.contact-row .stack-label {
  margin-bottom: 0;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.github-graph {
  display: flex;
  flex-direction: column;
}

.contribution-graph {
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
  overflow: hidden;
}

.contact-subject,
.contact-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color 0.15s;
}

.contact-subject::placeholder,
.contact-body::placeholder {
  color: var(--text-muted);
}

.contact-subject:focus,
.contact-body:focus {
  border-color: var(--highlight);
}

.contact-body {
  min-height: 220px;
  resize: none;
  overflow: hidden;
}

.contact-submit {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: white;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.contact-submit:hover {
  border-color: var(--highlight);
  color: var(--highlight);
}

/* ── Mobile ──────────────────────────────────────────────── */

@media (max-width: 767px) {
  body {
    padding: 0 1rem;
  }

  /* Header stacks vertically, centred */
  header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-top: 1.5rem;
    gap: 1.5rem;
  }

  .header-left {
    align-items: center;
    flex: none;
    width: 100%;
    padding-right: 0;
    border-right: none;
  }

  .header-right {
    padding-left: 0;
  }

  .profile-intro {
    flex-direction: column;
    gap: 0.75rem;
  }

  .profile-text {
    text-align: center;
    align-items: center;
  }

  .name-row {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }


  .bio {
    max-width: 100%;
  }

  .header-right {
    flex: none;
    width: 100%;
    text-align: center;
  }

  .tech-tags {
    justify-content: center;
  }

  /* Cards stack vertically, images always below text */
  .project-card,
  .project-card:nth-child(odd),
  .project-card:nth-child(even) {
    flex-direction: column;
  }

  .project-info {
    padding: 1.5rem;
  }

  .project-images {
    min-height: 260px;
    /* always render after project-info */
    order: 10;
  }

  .layout-2h {
    flex: none;
    width: 100%;
    min-height: 0;
  }

  .gh-text {
    display: none;
  }

  .github-link {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: white;
    justify-content: center;
    gap: 0;
    padding: 0;
    transition: color 0.15s, border-color 0.15s;
  }

  .github-link .gh-icon-box {
    border: none;
    background: transparent;
    width: auto;
    height: auto;
  }

  .github-link:hover {
    color: var(--highlight);
    border-color: var(--highlight);
  }

  .github-link svg {
    width: 21px;
    height: 21px;
  }

  .contact-row {
    grid-template-columns: 1fr;
  }

  .contact-form {
    width: 100%;
  }

  .github-graph {
    width: 100%;
  }
}
