:root {
  --green: #43c463;
  --green-d: #2faa50;
  --green-soft: #e9f9ee;
  --bg: #cfe8d6;
  --bg-grad: linear-gradient(135deg, #4aa183 0%, #6cc486 50%, #8ad79a 100%);
  --card: #ffffff;
  --panel: #ffffff;
  --text: #2b2b2b;
  --muted: #7c8a87;
  --line: #eef0ef;
  --shadow: 0 30px 60px -20px rgba(0,0,0,.35);
  --radius: 6px;
}

[data-theme="dark"] {
  --green-soft: #1d3326;
  --card: #1f2624;
  --panel: #1f2624;
  --text: #e8efec;
  --muted: #9fb0ac;
  --line: #2c3531;
  --bg-grad: linear-gradient(135deg, #16241d 0%, #1b3328 50%, #14201a 100%);
  --shadow: 0 30px 60px -20px rgba(0,0,0,.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Poppins', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg-grad);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  overflow-x: hidden;          /* never allow sideways page scroll */
}

/* ===== utility rail ===== */
.rail {
  position: fixed;
  top: 40px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 30;
}
.rail-btn, .rail-nav {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 14px 30px -16px rgba(0,0,0,.4);
}
.rail-btn {
  width: 48px; height: 48px;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  transition: color .2s;
}
.rail-btn:hover { color: var(--green); }
.rail-nav {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  margin-top: 6px;
}
.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 10px;
  text-decoration: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .5px;
  text-transform: uppercase;
  transition: color .2s;
}
.nav-link i { font-size: 16px; }
.nav-link:hover, .nav-link.active { color: var(--green); }

/* ===== shell ===== */
.shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 26px;
  width: 100%;
  max-width: 1180px;
  align-items: start;
}

/* ===== profile card ===== */
.profile-card {
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 40px;
}
.profile-photo {
  position: relative;
  clip-path: polygon(0 0, 100% 0, 100% 88%, 0 100%);
}
.profile-photo img { width: 100%; display: block; }
.profile-body { padding: 18px 24px 8px; text-align: center; }
.profile-name { font-size: 26px; font-weight: 600; }
.profile-role {
  color: var(--green);
  font-weight: 500;
  margin-top: 4px;
  min-height: 22px;
}
.socials {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 16px 0 6px;
}
.socials a { color: var(--text); font-size: 16px; transition: color .2s, transform .2s; }
.socials a:hover { color: var(--green); transform: translateY(-2px); }
.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  margin-top: 14px;
}
.pa-btn {
  padding: 18px 8px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .6px;
  transition: background .2s, color .2s;
}
.pa-btn:first-child { border-right: 1px solid var(--line); }
.pa-btn:hover { background: var(--green); color: #fff; }

/* ===== panel ===== */
.panel {
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 40px 44px;
  min-height: 620px;
  min-width: 0;        /* allow the panel to shrink so inner scroll rows stay contained */
}
.profile-card { min-width: 0; }
.section { display: none; animation: fade .4s ease; }
.section.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.section-title {
  font-size: 30px;
  font-weight: 600;
  margin-bottom: 26px;
  position: relative;
}
.section-title.mt {
  margin-top: 40px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}
.section-title span {
  color: var(--green);
  background: var(--green-soft);
  padding: 0 6px;
  border-radius: 4px;
  margin-right: 1px;
}

/* ===== about ===== */
.about-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 30px 48px; align-items: start; }
.lead { font-weight: 600; font-size: 17px; margin-bottom: 12px; }
.about-intro p { color: var(--muted); line-height: 1.75; }
.about-facts { list-style: none; display: flex; flex-direction: column; gap: 16px; }
.about-facts li { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.about-facts b { word-break: break-word; }
.tag {
  align-self: flex-start;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
}
.about-facts b { font-weight: 500; }

/* services */
.services { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; align-items: stretch; }
.service {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 32px 24px;
  text-align: center;
  transition: transform .25s, box-shadow .25s;
}
.service:hover { transform: translateY(-6px); box-shadow: 0 18px 30px -18px rgba(0,0,0,.3); }
.service-icon {
  width: 64px; height: 64px;
  margin-bottom: 18px;
  display: grid; place-items: center;
  background: var(--green);
  color: #fff;
  font-size: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}
.service h3 { font-size: 17px; margin-bottom: 10px; }
.service p { color: var(--muted); font-size: 13px; line-height: 1.65; }

/* ===== resume ===== */
.resume-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.res-head { font-size: 16px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 22px; }
.res-head i { color: var(--green); margin-right: 8px; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.t-item { position: relative; margin-bottom: 26px; }
.t-item::before {
  content: ""; position: absolute; left: -20px; top: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 4px var(--green-soft);
}
.t-date {
  display: inline-block; font-size: 11px; color: var(--green);
  border: 1px solid var(--green); border-radius: 4px;
  padding: 2px 8px; margin-bottom: 8px;
}
.t-item h4 { font-size: 16px; }
.t-sub { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.t-item p:last-child { color: var(--muted); font-size: 13px; line-height: 1.6; }

/* skills */
.skills-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 36px; }
.skill-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.bar { height: 7px; background: var(--line); border-radius: 20px; overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--w); background: var(--green); border-radius: 20px; }

/* ===== works ===== */
.works-filter { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.filter {
  border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-weight: 500; font-size: 14px;
  padding: 6px 14px; border-radius: 20px; font-family: inherit;
  transition: background .2s, color .2s;
}
.filter.active, .filter:hover { background: var(--green); color: #fff; }
.works-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.work { border-radius: 8px; overflow: hidden; transition: transform .25s; }
.work:hover { transform: translateY(-6px); }
.work-thumb {
  position: relative;
  aspect-ratio: 4/3;
  display: grid; place-items: center;
  background: var(--green-soft);
  color: var(--green);
  font-size: 40px;
  overflow: hidden;
}
.work-thumb img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .35s;
}
.work:hover .work-thumb img { transform: scale(1.06); }
/* when the image is missing, hide it and show the fallback icon */
.work-thumb.empty img { display: none; }
.work-thumb:not(.empty) i { display: none; }
.work figcaption { padding: 12px 4px; text-align: center; }
.work figcaption b { display: block; font-size: 15px; }
.work figcaption span { color: var(--muted); font-size: 12px; }

.work-thumb img { cursor: zoom-in; }
.works-empty { color: var(--muted); font-size: 14px; padding: 20px 0; }

/* ===== lightbox ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
}
.lightbox[hidden] { display: none; }
.lb-img {
  max-width: 88vw; max-height: 86vh;
  border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.lb-close, .lb-nav {
  position: absolute; background: rgba(255,255,255,.12);
  color: #fff; border: none; cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s;
}
.lb-close:hover, .lb-nav:hover { background: var(--green); }
.lb-close { top: 22px; right: 26px; width: 46px; height: 46px; border-radius: 50%; font-size: 26px; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; font-size: 20px; }
.lb-prev { left: 24px; }
.lb-next { right: 24px; }
@media (max-width: 600px) {
  .lb-nav { width: 42px; height: 42px; }
  .lb-prev { left: 10px; } .lb-next { right: 10px; }
}

/* ===== contact ===== */
.contact-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; margin-bottom: 10px; }
.cf { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.cf b { font-weight: 500; }
.cf a { color: inherit; text-decoration: none; transition: color .2s; }
.cf a:hover { color: var(--green); }
.contact-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.contact-form input, .contact-form textarea {
  width: 100%; font-family: inherit; font-size: 14px;
  padding: 14px 16px; margin-top: 16px;
  border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--text); resize: vertical;
}
.contact-form .row input { margin-top: 0; }
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--green); }
.send-btn {
  margin-top: 16px; cursor: pointer; font-family: inherit;
  background: var(--green); color: #fff; border: none;
  padding: 14px 26px; border-radius: 6px;
  font-weight: 600; letter-spacing: .6px; font-size: 13px;
  transition: background .2s;
}
.send-btn:hover { background: var(--green-d); }
.form-note { margin-top: 14px; color: var(--green); font-size: 14px; font-weight: 500; }

/* ===== responsive ===== */
@media (max-width: 900px) {
  body {
    padding: 18px 14px 92px;   /* bottom space for the fixed nav bar */
    align-items: flex-start;
  }

  /* hamburger isn't needed — the bottom bar is always visible */
  #menuToggle { display: none; }

  /* dark-mode toggle floats in the top-left corner */
  .rail {
    flex-direction: row;
    top: 16px; left: 14px; right: auto;
    transform: none;
    gap: 10px;
  }
  #themeToggle {
    width: 44px; height: 44px;
    box-shadow: 0 10px 24px -10px rgba(0,0,0,.45);
  }

  /* section nav becomes an app-style bottom tab bar */
  .rail-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    margin: 0;
    padding: 9px 6px calc(9px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 30px -12px rgba(0,0,0,.22);
    z-index: 40;
  }
  .nav-link { flex: 1; padding: 6px 4px; gap: 4px; }
  .nav-link i { font-size: 18px; }

  /* single-column card + panel */
  .shell { grid-template-columns: 1fr; max-width: 560px; gap: 18px; }
  .profile-card { position: static; }
  .panel { padding: 28px 22px; min-height: auto; }

  /* keep the profile photo from getting too tall */
  .profile-photo { aspect-ratio: 1 / 1; }
  .profile-photo img {
    width: 100%; height: 100%;
    object-fit: cover; object-position: 50% 22%;
  }

  /* stack the multi-column sections */
  .about-grid, .resume-grid, .skills-grid,
  .contact-facts, .contact-form .row { grid-template-columns: 1fr; }
  .about-grid, .resume-grid { gap: 28px; }
  .services { grid-template-columns: 1fr 1fr; }
  .works-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }

  /* dividers between sub-sections get a touch tighter */
  .section-title.mt { margin-top: 34px; padding-top: 30px; }

  /* Works filters: one swipeable row instead of wrapping */
  .works-filter {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;            /* Firefox */
    padding-bottom: 4px;
  }
  .works-filter::-webkit-scrollbar { display: none; }   /* Chrome/Safari */
  .filter { flex: 0 0 auto; white-space: nowrap; }
}

@media (max-width: 540px) {
  .panel { padding: 24px 18px; }
  .section-title { font-size: 23px; margin-bottom: 22px; }
  .services { grid-template-columns: 1fr; }
  .works-grid { grid-template-columns: 1fr 1fr; }
  .profile-name { font-size: 24px; }
  .nav-link span { font-size: 9px; }
}
