/* ============================================
   Reset & Base
   ============================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --stm32: #0098da;
  --stm32-bg: #e0f0ff;
  --esp: #e7352b;
  --esp-bg: #ffe8e6;
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;
  --white: #ffffff;
  --border: #e7e5e4;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--white);
  color: var(--stone-900);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

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

img {
  max-width: 100%;
  height: auto;
}

/* ============================================
   Utilities
   ============================================ */
.container {
  width: 100%;
  max-width: 1152px;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 640px) {
  .container {
    padding: 0 1.5rem;
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 0 2rem;
  }
}

/* ============================================
   Navbar
   ============================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.navbar-inner {
  display: flex;
  height: 64px;
  align-items: center;
  justify-content: space-between;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--stone-900);
}

.navbar-logo-icon {
  display: flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--stone-900);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
}

.navbar-links {
  display: none;
  align-items: center;
  gap: 0.25rem;
}

.navbar-links a {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--stone-500);
  transition: background 0.15s, color 0.15s;
}

.navbar-links a:hover {
  background: var(--stone-50);
  color: var(--stone-700);
}

.navbar-links a.active {
  background: var(--stone-100);
  color: var(--stone-900);
}

.hamburger {
  display: flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 8px;
  color: var(--stone-500);
  cursor: pointer;
}

.hamburger:hover {
  background: var(--stone-100);
}

.hamburger svg {
  width: 20px;
  height: 20px;
}

@media (min-width: 640px) {
  .hamburger {
    display: none;
  }

  .navbar-links {
    display: flex;
  }
}

/* Mobile menu */
.mobile-menu {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--white);
  padding: 0 1rem 1rem;
}

.mobile-menu.open {
  display: block;
}

.mobile-menu a {
  display: block;
  padding: 0.625rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--stone-500);
  transition: background 0.15s, color 0.15s;
}

.mobile-menu a:hover {
  background: var(--stone-50);
  color: var(--stone-700);
}

.mobile-menu a.active {
  background: var(--stone-100);
  color: var(--stone-900);
}

.mobile-menu nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.75rem;
}

/* ============================================
   Footer
   ============================================ */
.footer {
  border-top: 1px solid var(--border);
  background: var(--white);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 1rem;
}

.footer-text {
  font-size: 0.875rem;
  color: var(--stone-500);
}

.footer-tag {
  font-size: 0.875rem;
  color: var(--stone-400);
}

@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
  }
}

/* ============================================
   Home Hero
   ============================================ */
.hero {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 5rem 0;
}

.hero-content {
  max-width: 42rem;
  margin: 0 auto;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--stone-100);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--stone-500);
  margin-bottom: 1.5rem;
}

.hero-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stone-400);
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--stone-900);
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--stone-500);
  max-width: 36rem;
  margin: 0 auto 2rem;
}

.hero-btn {
  display: inline-flex;
  height: 48px;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.5rem;
  border-radius: 12px;
  background: var(--stone-900);
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.hero-btn:hover {
  background: var(--stone-800);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.hero-btn svg {
  width: 16px;
  height: 16px;
}

@media (min-width: 640px) {
  .hero h1 {
    font-size: 3rem;
  }

  .hero p {
    font-size: 1.125rem;
  }
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 48rem;
  margin: 4rem auto 0;
}

.stat-card {
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--stone-200);
  background: var(--white);
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-value.stm32-color {
  color: var(--stm32);
}
.stat-value.esp-color {
  color: var(--esp);
}
.stat-value.neutral {
  color: var(--stone-700);
}

.stat-label {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--stone-500);
}

@media (min-width: 640px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================
   MCU Preview Cards (Home)
   ============================================ */
.section-features {
  border-top: 1px solid var(--stone-100);
  background: var(--stone-50);
  padding: 4rem 0;
}

.section-features h2 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--stone-900);
  margin-bottom: 2.5rem;
}

.chip-grid {
  display: grid;
  gap: 1.5rem;
}

.chip-card {
  display: block;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--stone-200);
  background: var(--white);
  transition: transform 0.2s, box-shadow 0.2s;
}

.chip-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.chip-badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: 8px;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.chip-badge.stm32 {
  background: var(--stm32-bg);
  color: var(--stm32);
}

.chip-badge.esp {
  background: var(--esp-bg);
  color: var(--esp);
}

.chip-card p {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--stone-500);
}

@media (min-width: 640px) {
  .chip-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .chip-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ============================================
   Hardware Hero
   ============================================ */
.hw-hero {
  border-bottom: 1px solid var(--stone-100);
  background: linear-gradient(to bottom, var(--stone-50), var(--white));
  padding: 4rem 0;
}

.hw-hero .hero-badge {
  margin-bottom: 1rem;
}

.hw-hero h1 {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--stone-900);
  margin-bottom: 1rem;
}

.hw-hero h1 span {
  display: block;
  color: var(--stone-400);
}

.hw-hero p {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--stone-500);
  max-width: 36rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .hw-hero h1 {
    font-size: 2.5rem;
  }

  .hw-hero p {
    font-size: 1rem;
  }
}

/* Tag pills */
.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tag-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
}

.tag-pill.stm32 {
  border: 1px solid rgba(0, 152, 218, 0.2);
  background: var(--stm32-bg);
  color: var(--stm32);
}

.tag-pill.esp {
  border: 1px solid rgba(231, 53, 43, 0.2);
  background: var(--esp-bg);
  color: var(--esp);
}

.tag-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.tag-pill.stm32 .tag-pill-dot {
  background: var(--stm32);
}
.tag-pill.esp .tag-pill-dot {
  background: var(--esp);
}

/* ============================================
   Hardware Sections
   ============================================ */
.hw-content {
  padding: 3rem 0;
}

.section-group {
  margin-bottom: 5rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-icon {
  display: flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}

.section-icon.stm32 {
  background: var(--stm32-bg);
}
.section-icon.esp {
  background: var(--esp-bg);
}

.section-icon svg {
  width: 20px;
  height: 20px;
}

.section-icon.stm32 svg {
  color: var(--stm32);
}
.section-icon.esp svg {
  color: var(--esp);
}

.section-title-group h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--stone-900);
}

.section-title-group p {
  font-size: 0.875rem;
  color: var(--stone-500);
}

.section-divider {
  height: 1px;
  margin-bottom: 2rem;
}

.section-divider.stm32 {
  background: linear-gradient(to right, rgba(0, 152, 218, 0.3), transparent);
}
.section-divider.esp {
  background: linear-gradient(to right, rgba(231, 53, 43, 0.3), transparent);
}

/* Family Name */
.family-name {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--stone-400);
  margin-bottom: 0.75rem;
}

.family-group {
  margin-bottom: 1.5rem;
}

.family-group:last-child {
  margin-bottom: 0;
}

/* ============================================
   Accordion (Device Group)
   ============================================ */
.accordion {
  border-radius: 12px;
  border: 1px solid var(--stone-200);
  background: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.5rem;
}

.accordion:last-child {
  margin-bottom: 0;
}

.accordion-header {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 12px;
}

.accordion-header:hover {
  background: var(--stone-50);
}

.accordion-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.device-name {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--stone-800);
}

.device-count {
  display: inline-flex;
  height: 20px;
  min-width: 20px;
  align-items: center;
  justify-content: center;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: var(--stone-200);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--stone-600);
}

.accordion-arrow {
  width: 16px;
  height: 16px;
  color: var(--stone-400);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.accordion.open .accordion-arrow {
  transform: rotate(180deg);
}

.accordion.open .accordion-header {
  border-bottom: 1px solid var(--stone-100);
  border-radius: 12px 12px 0 0;
}

.accordion-body {
  display: none;
  padding: 1rem 1.25rem;
}

.accordion.open .accordion-body {
  display: block;
}

/* ============================================
   Project Card
   ============================================ */
.project-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--stone-200);
  background: var(--white);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: fadeUp 0.5s ease-out forwards;
  opacity: 0;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.card-category-badge {
  display: inline-flex;
  padding: 0.1875rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.card-category-badge.stm32 {
  background: var(--stm32-bg);
  color: var(--stm32);
}

.card-category-badge.esp {
  background: var(--esp-bg);
  color: var(--esp);
}

.card-year {
  font-size: 0.75rem;
  color: var(--stone-400);
}

.card-device {
  margin-bottom: 0.75rem;
}

.card-device-chip {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 6px;
  background: var(--stone-100);
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--stone-600);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--stone-900);
  margin-bottom: 0.375rem;
}

.card-desc {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--stone-500);
  margin-bottom: 1rem;
  flex: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.card-tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 6px;
  background: var(--stone-50);
  font-size: 0.75rem;
  color: var(--stone-500);
  border: 1px solid var(--stone-200);
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--stone-100);
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--stone-500);
  transition: color 0.15s;
}

.card-link:hover {
  color: var(--stone-800);
}

.card-link svg {
  width: 14px;
  height: 14px;
}

/* Animation */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 639px) {
  .section-group {
    margin-bottom: 3rem;
  }

  .hw-content {
    padding: 2rem 0;
  }
}

/* ============================================
   About Page
   ============================================ */
.about-hero {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 5rem 0;
}

.about-hero-inner {
  max-width: 36rem;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.about-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--stone-900), var(--stone-600));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.about-avatar-text {
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
}

.about-name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--stone-900);
  margin-bottom: 0.375rem;
}

.about-subtitle {
  font-size: 1rem;
  color: var(--stone-400);
  margin-bottom: 0;
}

.about-divider {
  width: 3rem;
  height: 3px;
  border-radius: 2px;
  background: var(--stone-200);
  margin: 1.5rem auto;
}

.about-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
  margin-bottom: 1.5rem;
}

.about-card {
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--stone-200);
  background: var(--white);
  text-align: center;
}

.about-card-icon {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--stone-100);
  color: var(--stone-600);
  margin-bottom: 0.75rem;
}

.about-card-icon svg {
  width: 20px;
  height: 20px;
}

.about-card-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--stone-400);
  margin-bottom: 0.25rem;
}

.about-card-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--stone-800);
}

.about-link {
  color: var(--stm32);
  transition: color 0.15s;
}

.about-link:hover {
  color: #0070b0;
  text-decoration: underline;
}

.about-bio {
  width: 100%;
  text-align: left;
  margin-bottom: 2rem;
}

.about-bio p {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--stone-500);
}

.about-contact-btn {
  display: inline-flex;
  height: 48px;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.5rem;
  border-radius: 12px;
  background: var(--stone-900);
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
}

.about-contact-btn:hover {
  background: var(--stone-800);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.about-contact-btn svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 480px) {
  .about-cards {
    grid-template-columns: 1fr;
  }

  .about-name {
    font-size: 1.625rem;
  }
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
