/* ============================================================
   Portfolio styles
   Structure:
     1. Design tokens (:root)  ← change colors & type here
     2. Base / reset
     3. Layout helpers
     4. Header / nav
     5. Hero
     6. Work
     7. About
     8. Contact
     9. Footer
    10. Motion (reveal-on-scroll)
    11. Responsive
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --ink: #161618;
  --muted: #6b6b70;
  --line: #e6e5e1;
  --accent: #0f7a55;
  --accent-tint: #e6f3ee;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --max: 1040px;
  --pad: clamp(1.25rem, 5vw, 4rem);
  --section-gap: clamp(5rem, 12vw, 9rem);

  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Dark theme — applied when <html data-theme="dark"> (toggled in script.js).
   Light is the default (the :root values above). */
:root[data-theme="dark"] {
  --bg: #121316;
  --surface: #1a1b1f;
  --ink: #ededec;
  --muted: #9a9aa0;
  --line: #2a2b30;
  --accent: #4cc79a;
  --accent-tint: #14271f;
}

/* ---------- 2. Base / reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 600;
}

/* ---------- 3. Layout helpers ---------- */
.section {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--pad);
  padding-block: var(--section-gap);
}

/* trim the big top gap on the first section under the header */
.hero.section {
  padding-top: clamp(3rem, 9vw, 6rem);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  margin-bottom: 2.5rem;
}

/* ---------- 4. Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max);
  margin-inline: auto;
  padding: 1.1rem var(--pad);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  gap: 2rem;
}

.nav a {
  font-size: 0.95rem;
  color: var(--muted);
  position: relative;
  transition: color 0.2s var(--ease);
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--ease);
}

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

.nav a:hover::after,
.nav a:focus-visible::after {
  transform: scaleX(1);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 6px;
}

.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--ink);
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Show the icon for the mode you'll switch *to* */
.icon-sun { display: none; }
.icon-moon { display: block; }

:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---------- 5. Hero ---------- */
.hero-title {
  font-size: clamp(2.4rem, 7vw, 4.25rem);
  font-weight: 700;
  margin-bottom: 1.75rem;
}

.cursor {
  display: inline-block;
  width: 0.55ch;
  height: 1em;
  margin-left: 0.1em;
  background: var(--accent);
  vertical-align: -0.12em;
  animation: blink 1.1s steps(2, start) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.hero-intro {
  max-width: 46ch;
  color: var(--muted);
  font-size: 1.15rem;
  margin-bottom: 2.5rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.7rem 1.4rem;
  border-radius: 100px;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease),
    border-color 0.2s var(--ease);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  transform: translateY(-2px);
}

.btn-ghost {
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 6. Work ---------- */
.work-list {
  display: flex;
  flex-direction: column;
}

.project {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  padding: 2rem 0;
  border-top: 1px solid var(--line);
  transition: padding-left 0.3s var(--ease);
}

.project:last-child {
  border-bottom: 1px solid var(--line);
}

.project:hover {
  padding-left: 0.75rem;
}

.project-index {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--muted);
  padding-top: 0.4rem;
}

.project-title {
  font-size: 1.4rem;
  margin-bottom: 0.6rem;
}

.project-title a {
  position: relative;
}

.project-title a::after {
  content: "↗";
  font-family: var(--font-body);
  font-size: 0.75em;
  margin-left: 0.35em;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  display: inline-block;
}

.project-title a:hover::after,
.project-title a:focus-visible::after {
  opacity: 1;
  transform: translate(2px, -2px);
}

.project-desc {
  color: var(--muted);
  max-width: 56ch;
  margin-bottom: 0.9rem;
}

.project-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- 7. About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: clamp(2rem, 6vw, 5rem);
}

.about-text p {
  color: var(--muted);
  margin-bottom: 1.2rem;
  max-width: 52ch;
}

.about-text p:first-of-type {
  color: var(--ink);
}

.skills {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.skill-group h4 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.6rem;
  font-weight: 500;
}

.skill-group ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
}

.skill-group li {
  font-size: 0.95rem;
}

.credentials {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 6vw, 5rem);
  margin-top: clamp(3rem, 7vw, 5rem);
  padding-top: 2.5rem;
  border-top: 1px solid var(--line);
}

.cred-detail {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- GitHub Dashboard ---------- */
.stats-section {
  padding-block-start: 0;
}

#projects.section {
  padding-block-start: 0;
}

.cp-section {
  padding-block-start: 0;
}

.gh-dashboard,
.cp-dashboard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 4vw, 2.5rem);
}

.gh-dashboard-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.gh-divider {
  width: 40px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 1rem 0 1.75rem;
}

/* --- 3×2 stat cards --- */
.gh-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.gh-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.4rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.gh-stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.gh-stat-icon {
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.gh-stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.gh-stat-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
}

/* --- Contribution heatmap --- */
.gh-contrib {
  margin-bottom: 2rem;
}

.gh-sub-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.gh-contrib-graph {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
}

.gh-contrib-graph img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}

/* Invert the heatmap in dark mode so it stays readable */
:root[data-theme="dark"] .gh-contrib-graph img {
  filter: invert(1) hue-rotate(180deg);
  opacity: 0.85;
}

/* --- Recent activity feed --- */
.gh-activity-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.gh-activity-loading {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.gh-event {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  transition: border-color 0.2s var(--ease);
  position: relative;
  padding-left: 1.5rem;
}

.gh-event::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 3px 0 0 3px;
}

.gh-event:hover {
  border-color: var(--accent);
}

.gh-event-dot {
  width: 8px;
  height: 8px;
  background: var(--ink);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.45rem;
}

.gh-event-body {
  flex: 1;
  min-width: 0;
}

.gh-event-text {
  font-size: 0.92rem;
  line-height: 1.4;
}

.gh-event-text strong {
  font-weight: 600;
}

.gh-event-time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* --- Competitive Programming cards --- */
.cp-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.cp-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.cp-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.cp-card-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.cp-card-platform {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
}

.cp-card-handle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.cp-card-stats {
  display: flex;
  gap: 2rem;
}

.cp-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.cp-stat-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.cp-stat-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.cp-rank-badge {
  font-size: 1rem;
  color: var(--accent);
}

/* ---------- 8. Contact ---------- */
.contact-title {
  font-size: clamp(2rem, 6vw, 3.25rem);
  margin-bottom: 1rem;
}

.contact-intro {
  color: var(--muted);
  max-width: 44ch;
  margin-bottom: 2rem;
}

.contact-email {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 600;
  color: var(--accent);
  position: relative;
}

.contact-email::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}

.contact-email:hover::after,
.contact-email:focus-visible::after {
  transform: scaleX(1);
}

.socials {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem;
  margin-top: 3rem;
}

.socials a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}

.socials a:hover,
.socials a:focus-visible {
  color: var(--ink);
}

/* ---------- 9. Footer ---------- */
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: var(--max);
  margin-inline: auto;
  padding: 2.5rem var(--pad);
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- 10. Motion (reveal-on-scroll) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

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

/* ---------- 11. Responsive ---------- */
@media (max-width: 720px) {
  .nav-toggle {
    display: flex;
  }

  .header-right {
    gap: 0.85rem;
  }

  .nav {
    position: absolute;
    top: 100%;
    right: var(--pad);
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.5rem 1.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease),
      visibility 0.2s;
  }

  .nav.open {
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .credentials {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .gh-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cp-cards {
    grid-template-columns: 1fr;
  }

  .cp-card-stats {
    gap: 1.25rem;
  }

  .project:hover {
    padding-left: 0;
  }
}
