/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --bg: #F8F7F2;
  --surface: #FFFFFF;
  --text: #141420;
  --muted: #6C6C7A;
  --accent: #E04D20;
  --accent-hover: #B83D17;
  --border: #E6E5DF;
  --shadow-sm: 0 1px 3px rgba(20, 20, 32, 0.06);
  --shadow: 0 4px 16px rgba(20, 20, 32, 0.09);

  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-display-title: "Honk", system-ui;

  --nav-h: 64px;
  --max-w: 1100px;
  --radius: 10px;

  /* GitHub language colors */
  --c-python: #3572A5;
  --c-rust: #CE6E00;
  --c-csharp: #178600;
  --c-elk: #00BFB3;
  --c-other: #888;

  /* External profile accent colors */
  --c-gcp: #4285F4;
  --c-vercel: #000000;
  --c-itch: #FA5C5C;
}

/* ============================================================
   DARK MODE
   ============================================================ */
[data-theme="dark"] {
  --bg: #121212;
  --surface: #1E1E1E;
  --text: #E4E4E7;
  --muted: #A1A1AA;
  --border: #27272A;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .nav.scrolled {
  background: rgba(18, 18, 18, 0.92);
}
[data-theme="dark"] .btn-primary {
  color: #fff;
}

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  padding-top: var(--nav-h);
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}
.section {
  padding: 5rem 0;
}

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s, background 0.25s;
}
.nav.scrolled {
  border-color: var(--border);
  background: rgba(248, 247, 242, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  transition: color 0.15s;
}
.nav-logo:hover { color: var(--accent); }
.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}
.nav-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.15s;
  position: relative;
  padding-bottom: 2px;
}
.nav-link:hover { color: var(--text); }
.nav-link.active {
  color: var(--text);
}
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* theme toggle */
.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--muted);
  padding: 0 0 2px;
  transition: color 0.15s;
  font-family: inherit;
}
.theme-btn:hover {
  color: var(--text);
}

/* hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-direction: column;
  gap: 5px;
  align-items: center;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   DROPDOWN NAV
   ============================================================ */
.nav-dropdown {
  position: relative;
}
.nav-dropdown > .nav-link {
  cursor: default;
  display: inline-flex;
  align-items: center;
}
.dropdown-arrow {
  font-size: 0.6rem;
  margin-left: 3px;
  transition: transform 0.2s ease;
}
.nav-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0;
  min-width: 130px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  box-shadow: var(--shadow);
  z-index: 200;
}
.nav-dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
}
.dropdown-menu li {
  width: 100%;
}
.dropdown-menu .nav-link {
  display: block;
  padding: 0.35rem 1.1rem;
  white-space: nowrap;
  border-radius: 0;
}
.dropdown-menu .nav-link:hover {
  color: var(--text);
  background: var(--bg);
}

/* ============================================================
   HERO (index.html only)
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem 24px 5rem;
  max-width: var(--max-w);
  margin: 0 auto;
}
.hero::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.035;
  top: -200px;
  right: -200px;
  z-index: -1;
  animation: hero-float 8s ease-in-out infinite;
}
.hero::after {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  border: 2px solid var(--accent);
  opacity: 0.06;
  border-radius: 0;
  transform: rotate(45deg);
  bottom: 60px;
  left: -80px;
  z-index: -1;
}
[data-theme="dark"] .hero::before {
  opacity: 0.07;
}
[data-theme="dark"] .hero::after {
  opacity: 0.12;
}
@keyframes hero-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}
.hero-name {
  font-family: var(--font-display-title);
  font-weight: 800;
  font-size: clamp(4rem, 12vw, 9rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  margin-bottom: 2rem;
}
.hero-name .accent { color: var(--accent); }
.hero-role {
  font-family: var(--font-mono);
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--muted);
  margin-bottom: 1.75rem;
  min-height: 1.8em;
}
.hero-role::before {
  content: '// ';
  color: var(--border);
  user-select: none;
}
.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.hero-bio {
  max-width: 500px;
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.75;
  margin-bottom: 2.5rem;
}
.hero-ctas {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.hero-ctas-sub {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.hero-ctas-sub .btn {
  font-size: 0.82rem;
  padding: 0.45rem 1rem;
  border-width: 1px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-body);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  border: 1.5px solid transparent;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover {
  border-color: var(--text);
  transform: translateY(-1px);
}

/* ============================================================
   SECTION HEADINGS
   ============================================================ */
.section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 0.5rem;
}
.section-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 2.75rem;
}

/* ============================================================
   PROJECT CARDS
   ============================================================ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  position: relative;
  overflow: hidden;
}
/* colored top border using the language color */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--border));
  border-radius: var(--radius) var(--radius) 0 0;
}
.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.card-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 0.25rem;
}
.card-desc {
  font-size: 0.875rem;
  color: var(--muted);
  flex: 1;
  line-height: 1.55;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.card-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.2rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  white-space: nowrap;
}
.card-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.2rem;
  white-space: nowrap;
  transition: gap 0.15s ease;
}
.card-link:hover { gap: 0.45rem; }
/* FILTER BAR */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.filter-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.filter-btn:hover {
  color: var(--text);
  border-color: var(--text);
}
.filter-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}
.card.hidden {
  display: none;
}

.card-more {
  margin-top: 2.25rem;
  text-align: center;
}

/* ============================================================
   PROFILE CARDS (profiles.html) — extends .card
   ============================================================ */
.profile-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.profile-badge-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ============================================================
   BADGE GALLERY (cloud.html)
   ============================================================ */
#badgeList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}
.badge-item {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.badge-item:hover {
  border-color: var(--accent);
}
.badge-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 0.25rem;
}
.badge-date {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--font-mono);
}
.badge-count {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 1.5rem;
}

/* ============================================================
   PAGE HEADER (sub-pages)
   ============================================================ */
.page-header {
  padding: 3.5rem 0 3rem;
  border-bottom: 1px solid var(--border);
}
.page-header-sub {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 480px;
  margin-top: 0.75rem;
  line-height: 1.65;
}

/* ============================================================
   3D BACKGROUND (cyber page)
   ============================================================ */
.page-header.has-bg {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  display: flex;
  align-items: center;
}
.page-header.has-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to bottom, transparent 50%, var(--bg) 100%);
  pointer-events: none;
}
.bg-3d {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.page-header.has-bg .container {
  position: relative;
  z-index: 2;
}

/* ============================================================
   3D BACKGROUND FULL-PAGE (ML page)
   ============================================================ */
.bg-3d-full {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
[data-page="ml"] main,
[data-page="cloud"] main {
  position: relative;
  z-index: 1;
}

/* ============================================================
   ABOUT PAGE
   ============================================================ */
.about-photo-wrapper {
  text-align: center;
  margin-bottom: 3rem;
}
.about-photo {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  box-shadow: var(--shadow);
  display: inline-block;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 5rem;
  align-items: start;
}
.skills-group {
  margin-bottom: 2rem;
}
.skills-group:last-child { margin-bottom: 0; }
.skills-group-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.65rem;
}
.skills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.pill {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.25rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  transition: border-color 0.15s;
}
.pill:hover { border-color: var(--accent); }

.bio-para {
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 1.25rem;
}
.bio-para:last-of-type { margin-bottom: 0; }
.bio-para strong {
  color: var(--text);
  font-weight: 600;
}

.currently-box {
  margin-top: 2.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.currently-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.currently-text {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.65;
}

/* ============================================================
   CONTACT PAGE
   ============================================================ */
.contact-wrapper {
  max-width: 620px;
  padding: 5rem 0;
}
.contact-intro {
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.75;
  margin-top: 0.75rem;
}
.contact-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2.75rem;
}
.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.contact-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.contact-card-platform {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.contact-card-handle {
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.contact-card-cta {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 0.25rem;
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-text {
  font-size: 0.82rem;
  color: var(--muted);
}
.footer-links {
  display: flex;
  gap: 1.5rem;
}
.footer-link {
  font-size: 0.82rem;
  color: var(--muted);
  transition: color 0.15s;
}
.footer-link:hover { color: var(--text); }

/* ============================================================
   BACK TO TOP
   ============================================================ */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 99;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}
.back-to-top:hover {
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* ============================================================
   FADE-IN ANIMATIONS
   ============================================================ */
.fade-in {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .about-grid { grid-template-columns: 1fr; gap: 3rem; }
}

@media (max-width: 640px) {
  .projects-grid { grid-template-columns: 1fr; }
  .contact-cards { grid-template-columns: 1fr; }

  .nav-links {
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1.5rem 24px 2rem;
    gap: 1.25rem;
    align-items: flex-start;
    box-shadow: var(--shadow);
    pointer-events: none;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.3s ease;
  }
  .nav-links.open {
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
  }
  .nav-toggle { display: flex; }

  /* dropdown inline on mobile */
  .nav-dropdown {
    width: 100%;
  }
  .dropdown-menu {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    display: none;
    box-shadow: none;
    border: none;
    padding: 0 0 0 1rem;
    background: transparent;
    min-width: auto;
  }
  .nav-dropdown.open .dropdown-menu {
    display: block;
  }

  .hero-name { font-size: clamp(3.25rem, 14vw, 5rem); }
  .section { padding: 3.5rem 0; }
  .page-header { padding: 2.5rem 0 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .cursor { animation: none; opacity: 1; }
}