/* ============================================================
   CAIO MOREIRA CANCELA — PORTFOLIO STYLESHEET
   Design: Space Grotesk + Inter | Dark-first | CSS Variables
   ============================================================ */

/* ---- RESET & BASE ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

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

ul {
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ============================================================
   THEME: CSS VARIABLES
   ============================================================ */
:root,
[data-theme="dark"] {
  /* Background layers */
  --bg-primary:       #0A0F1C;
  --bg-secondary:     #0F1628;
  --bg-card:          #141C30;
  --bg-card-hover:    #1A2540;

  /* Text */
  --text-primary:     #E8EAF0;
  --text-secondary:   #8B92A8;
  --text-muted:       #4E5568;

  /* Accent */
  --accent:           #00D4FF;
  --accent-dim:       rgba(0, 212, 255, 0.12);
  --accent-glow:      rgba(0, 212, 255, 0.25);

  /* Borders */
  --border:           rgba(255, 255, 255, 0.07);
  --border-accent:    rgba(0, 212, 255, 0.3);

  /* Grid texture */
  --grid-color:       rgba(255, 255, 255, 0.025);

  /* Shadows */
  --shadow-card:      0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-glow:      0 0 32px rgba(0, 212, 255, 0.15);

  /* Nav */
  --nav-bg:           rgba(10, 15, 28, 0.88);
}

[data-theme="light"] {
  --bg-primary:       #F4F6FB;
  --bg-secondary:     #EAECF4;
  --bg-card:          #FFFFFF;
  --bg-card-hover:    #F0F2FA;

  --text-primary:     #131825;
  --text-secondary:   #4E5A72;
  --text-muted:       #9EA8BD;

  --accent:           #0099CC;
  --accent-dim:       rgba(0, 153, 204, 0.1);
  --accent-glow:      rgba(0, 153, 204, 0.2);

  --border:           rgba(0, 0, 0, 0.08);
  --border-accent:    rgba(0, 153, 204, 0.3);

  --grid-color:       rgba(0, 0, 0, 0.03);

  --shadow-card:      0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-glow:      0 0 32px rgba(0, 153, 204, 0.12);

  --nav-bg:           rgba(244, 246, 251, 0.9);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.accent {
  color: var(--accent);
}

.section-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  margin-bottom: 2.5rem;
}

/* ============================================================
   BACKGROUND GRID TEXTURE (signature element)
   ============================================================ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
  transition: background-image 0.3s ease;
}

/* ============================================================
   LAYOUT CONTAINERS
   ============================================================ */
.site-header,
main,
.site-footer {
  position: relative;
  z-index: 1;
}

.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 6rem 1.5rem 4rem;
  min-height: calc(100vh - 72px);
}

.page.hidden {
  display: none;
}

/* ============================================================
   HEADER & NAV
   ============================================================ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: 72px;
  display: flex;
  align-items: center;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.nav-container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Logo */
.nav-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.2s;
}

.logo-bracket {
  color: var(--accent);
}

/* Nav links */
.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-link {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.45rem 1rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* Nav controls */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-dim);
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 8px;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger.open span:nth-child(2) {
  opacity: 0;
}
.hamburger.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
  min-height: 80vh;
  padding-top: 2rem;
}

.hero-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

.hero-name {
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  line-height: 1.1;
}

.name-accent {
  color: var(--accent);
  display: block;
}

.hero-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0;
}

/* Terminal cursor blink — the design's signature */
.cursor {
  color: var(--accent);
  font-weight: 700;
  animation: blink 1.1s step-start infinite;
  margin-left: 2px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.hero-about {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin-bottom: 2rem;
  line-height: 1.75;
}

/* Hero buttons */
.hero-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

/* Social links */
.social-links {
  display: flex;
  gap: 0.75rem;
}

.social-link {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.05rem;
  transition: all 0.25s ease;
}

.social-link:hover {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-dim);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}

/* Photo frame */
.hero-photo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.photo-frame {
  position: relative;
  width: 340px;
  height: 380px;
}

.profile-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20px;
  border: 1px solid var(--border-accent);
  box-shadow: var(--shadow-glow);
  transition: box-shadow 0.3s ease;
}

.photo-frame::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 24px;
  border: 1px solid var(--accent-dim);
  pointer-events: none;
}

.photo-badge {
  position: absolute;
  bottom: -16px;
  right: -16px;
  width: 60px;
  height: 60px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #0A0F1C;
  box-shadow: 0 8px 24px var(--accent-glow);
}

/* ============================================================
   STATS STRIP
   ============================================================ */
.stats-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  margin: 3rem 0 4rem;
}

.stat-item {
  flex: 1;
  min-width: 140px;
  text-align: center;
  padding: 0.5rem 1rem;
}

.stat-number {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-top: 0.2rem;
  display: block;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  flex-shrink: 0;
}

/* ============================================================
   SKILLS SECTION
   ============================================================ */
.skills-section {
  margin-bottom: 5rem;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.skill-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  transition: all 0.25s ease;
  cursor: default;
}

.skill-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-card);
}

.skill-icon {
  width: 44px;
  height: 44px;
  background: var(--accent-dim);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

.skill-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.skill-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ============================================================
   TIMELINE SECTION
   ============================================================ */
.timeline-section {
  margin-bottom: 2rem;
}

.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 2.5rem;
  padding-left: 1.5rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -1.95rem;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  flex-shrink: 0;
}

.timeline-marker.is-edu {
  border-color: var(--text-muted);
  box-shadow: none;
}

.timeline-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  transition: border-color 0.2s;
}

.timeline-content:hover {
  border-color: var(--border-accent);
}

.timeline-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
  display: block;
}

.timeline-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.timeline-company {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.timeline-content p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.7rem 1.5rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #0A0F1C;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--accent-glow);
  filter: brightness(1.1);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-2px);
}

/* ============================================================
   PORTFOLIO PAGE
   ============================================================ */
.portfolio-header {
  text-align: center;
  padding: 1rem 0 2.5rem;
}

.portfolio-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: -1.5rem;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}

.filter-btn {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover,
.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 4rem;
}

/* Project Card */
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.28s ease;
  position: relative;
  overflow: hidden;
}

.project-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  opacity: 0;
  box-shadow: inset 0 0 0 1px var(--accent);
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.project-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-card);
  background: var(--bg-card-hover);
}

.project-card:hover::after {
  opacity: 1;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-dim);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--accent);
}

.card-links {
  display: flex;
  gap: 0.5rem;
}

.card-link {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.card-link:hover {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-dim);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
  flex: 1;
}

/* Tech Tags */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
}

.tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-glow);
  white-space: nowrap;
}

/* Hidden cards (filtered out) */
.project-card.filtered-out {
  display: none;
}

/* ============================================================
   CONTACT CTA
   ============================================================ */
.contact-cta {
  text-align: center;
  padding: 3.5rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  margin-top: 1rem;
}

.contact-cta h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  margin-bottom: 0.75rem;
}

.contact-cta p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 1.5rem;
}

.footer-inner {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 500;
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-socials {
  display: flex;
  gap: 0.65rem;
}

.footer-socials a {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.footer-socials a:hover {
  color: var(--accent);
  border-color: var(--border-accent);
}

/* ============================================================
   SCROLL REVEAL ANIMATION
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   RESPONSIVE — TABLET & BELOW (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {

  .hero-grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 2.5rem;
    min-height: unset;
    padding-top: 1rem;
  }

  .hero-content {
    order: 2;
  }

  .hero-photo-wrap {
    order: 1;
  }

  .hero-eyebrow,
  .hero-actions,
  .social-links {
    justify-content: center;
  }

  .hero-about {
    margin-left: auto;
    margin-right: auto;
  }

  .photo-frame {
    width: 240px;
    height: 270px;
  }

  .stat-divider {
    display: none;
  }

  .stats-strip {
    gap: 1rem;
  }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {

  .page {
    padding: 5.5rem 1rem 3rem;
  }

  /* Show hamburger, hide desktop nav */
  .hamburger {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: 72px;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1.5rem;
    gap: 0.5rem;
    transform: translateY(-110%);
    transition: transform 0.3s ease;
    z-index: 99;
  }

  .nav-links.open {
    transform: translateY(0);
  }

  .nav-link {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    width: 100%;
    text-align: center;
  }

  .hero-name {
    font-size: 2.2rem;
  }

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

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

  .footer-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .stats-strip {
    flex-direction: column;
    gap: 1.5rem;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
