/* ── TOKENS ───────────────────────────────────────────── */
:root {
  --bg:        #0A0A0A;
  --bg-card:   #141414;
  --fg:        #F0EFE9;
  --fg-muted:  #6B6B6B;
  --fg-dim:    #2E2E2E;
  --accent:    #7EB8C9;
  --border:    rgba(255,255,255,0.07);
  --radius:    2px;
  --mono:      'JetBrains Mono', monospace;
  --serif:     'Cormorant Garamond', Georgia, serif;
  --sans:      'Inter', system-ui, sans-serif;
  --transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg:       #F7F6F2;
  --bg-card:  #EFEFEB;
  --fg:       #0A0A0A;
  --fg-muted: #888880;
  --fg-dim:   #D8D8D4;
  --border:   rgba(0,0,0,0.07);
}

[data-theme="terminal"] {
  --bg:       #0A0A0A;
  --bg-card:  #0A0A0A;
  --fg:       #39FF14;
  --fg-muted: #1A7A00;
  --fg-dim:   #0A2A00;
  --accent:   #39FF14;
  --border:   rgba(57,255,20,0.12);
  --sans:     'JetBrains Mono', monospace;
  --serif:    'JetBrains Mono', monospace;
}

/* ── LANGUAGE BLOCKS ──────────────────────────────────── */
.t-en, .t-pt { display: none; }
[data-lang="en"] .t-en { display: block; }
[data-lang="pt"] .t-pt { display: block; }
span.t-en, span.t-pt { display: none; }
[data-lang="en"] span.t-en { display: inline; }
[data-lang="pt"] span.t-pt { display: inline; }

/* ── RESET ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  font-weight: 300;
  letter-spacing: 0.01em;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ── CURSOR ───────────────────────────────────────────── */
[data-theme="dark"] body,
[data-theme="light"] body { cursor: none; }
[data-theme="terminal"] body { cursor: default; }

.cursor-dot {
  position: fixed;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
}
[data-theme="terminal"] .cursor-dot { display: none; }
@media (hover: none) { .cursor-dot { display: none; } }

/* ── BLACK HOLE CANVAS ────────────────────────────────── */
#spikesCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  display: block;
}
[data-theme="terminal"] #spikesCanvas { display: none; }

/* ── BINARY CANVAS ────────────────────────────────────── */
#binaryCanvas {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
[data-theme="terminal"] #binaryCanvas { display: block; }

/* ── SCANLINES (terminal only) ────────────────────────── */
[data-theme="terminal"] body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 3px,
    rgba(0,0,0,0.15) 3px, rgba(0,0,0,0.15) 4px
  );
}

/* ── NOISE TEXTURE ────────────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* ── LAYOUT ───────────────────────────────────────────── */
.site-wrap {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* ── SIDEBAR ──────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 260px;
  height: 100vh;
  padding: 40px 28px;
  display: flex;
  flex-direction: column;
  background: transparent;
  z-index: 10;
}

.sidebar-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 300;
  letter-spacing: 0.02em;
  margin-bottom: 48px;
  line-height: 1.2;
}

.sidebar-name span {
  display: block;
  font-size: 11px;
  font-family: var(--sans);
  font-weight: 400;
  color: var(--fg-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 4px;
  transition: color var(--transition);
}

/* ── NAV ──────────────────────────────────────────────── */
nav ul { display: flex; flex-direction: column; gap: 2px; }

nav a {
  display: inline-block;
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-muted);
  padding: 5px 8px;
  letter-spacing: 0.06em;
  transition: color 0.2s ease, background 0.2s ease;
  text-transform: uppercase;
  width: fit-content;
}

[data-theme="dark"] nav a:hover,
[data-theme="dark"] nav a.active { background: #F0EFE9; color: #0A0A0A; }
[data-theme="light"] nav a:hover,
[data-theme="light"] nav a.active { background: #0A0A0A; color: #F7F6F2; }
[data-theme="terminal"] nav a:hover,
[data-theme="terminal"] nav a.active { background: #39FF14; color: #0A0A0A; }

/* ── SUBMENU ──────────────────────────────────────────── */
.nav-item-expandable { display: flex; flex-direction: column; }
.nav-parent { cursor: pointer; }
.nav-parent::after { content: ' ›'; font-size: 11px; transition: transform 0.3s ease; display: inline-block; margin-left: 2px; }
.nav-parent.open::after { transform: rotate(90deg); }
.subnav { overflow: hidden; max-height: 0; transition: max-height 0.35s cubic-bezier(0.16,1,0.3,1); padding-left: 16px; }
.subnav.open { max-height: 100px; }
.subnav-link { font-size: 12px !important; padding: 3px 8px !important; }

/* ── SIDEBAR BOTTOM ───────────────────────────────────── */
.sidebar-bottom { margin-top: auto; }

.theme-switcher { display: flex; flex-direction: column; gap: 2px; margin-bottom: 24px; }

.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  color: var(--fg-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 0;
  text-align: left;
  transition: color 0.2s ease;
}
.theme-btn:hover { color: var(--fg); }
.theme-btn.active { color: var(--accent); }

.lang-switcher { display: flex; gap: 8px; margin-bottom: 16px; margin-top: 8px; }

.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  color: var(--fg-muted);
  letter-spacing: 0.1em;
  padding: 4px 0;
  transition: color 0.2s ease;
}
.lang-btn:hover { color: var(--fg); }
.lang-btn.active { color: var(--accent); }

.terminal-hint {
  font-size: 11px;
  color: var(--fg-muted);
  letter-spacing: 0.06em;
  line-height: 1.6;
  margin-bottom: 20px;
  transition: color var(--transition), opacity var(--transition);
}
.terminal-hint-arrow { display: block; font-size: 16px; color: var(--accent); margin-bottom: 4px; animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
[data-theme="terminal"] .terminal-hint { display: none; }

.sidebar-copy { font-size: 11px; color: var(--fg-muted); letter-spacing: 0.06em; transition: color var(--transition); }

/* ── TEXT HIGHLIGHT — dark (preto sólido atrás do texto) ─ */
[data-theme="dark"] .hero-eyebrow,
[data-theme="dark"] .hero-bio p,
[data-theme="dark"] .hero-title,
[data-theme="dark"] .section-label,
[data-theme="dark"] .project-name a,
[data-theme="dark"] .project-name,
[data-theme="dark"] .project-desc,
[data-theme="dark"] .project-date,
[data-theme="dark"] .project-links a,
[data-theme="dark"] .about-text p,
[data-theme="dark"] .stat-number,
[data-theme="dark"] .stat-label,
[data-theme="dark"] .contact-heading,
[data-theme="dark"] .contact-link,
[data-theme="dark"] .sidebar-name,
[data-theme="dark"] .sidebar-copy,
[data-theme="dark"] .terminal-hint,
[data-theme="dark"] .theme-btn,
[data-theme="dark"] .lang-btn,
[data-theme="dark"] nav a {
  background: #0A0A0A;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding-left: 4px;
  padding-right: 4px;
}

/* ── TEXT HIGHLIGHT — light (branco sólido atrás do texto) */
[data-theme="light"] .hero-eyebrow,
[data-theme="light"] .hero-bio p,
[data-theme="light"] .hero-title,
[data-theme="light"] .section-label,
[data-theme="light"] .project-name a,
[data-theme="light"] .project-name,
[data-theme="light"] .project-desc,
[data-theme="light"] .project-date,
[data-theme="light"] .project-links a,
[data-theme="light"] .about-text p,
[data-theme="light"] .stat-number,
[data-theme="light"] .stat-label,
[data-theme="light"] .contact-heading,
[data-theme="light"] .contact-link,
[data-theme="light"] .sidebar-name,
[data-theme="light"] .sidebar-copy,
[data-theme="light"] .terminal-hint,
[data-theme="light"] .theme-btn,
[data-theme="light"] .lang-btn,
[data-theme="light"] nav a {
  background: #F7F6F2;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding-left: 4px;
  padding-right: 4px;
}

/* nav hover/active sobrescreve */
[data-theme="dark"] nav a:hover,
[data-theme="dark"] nav a.active { background: #F0EFE9; color: #0A0A0A; }
[data-theme="light"] nav a:hover,
[data-theme="light"] nav a.active { background: #0A0A0A; color: #F7F6F2; }

/* ── TEXT HIGHLIGHT — terminal (preto + box-shadow) ──── */
[data-theme="terminal"] .hero-eyebrow,
[data-theme="terminal"] .hero-bio,
[data-theme="terminal"] .hero-title,
[data-theme="terminal"] .section-label,
[data-theme="terminal"] .project-name,
[data-theme="terminal"] .project-desc,
[data-theme="terminal"] .project-date,
[data-theme="terminal"] .project-links,
[data-theme="terminal"] .about-text p,
[data-theme="terminal"] .stat-number,
[data-theme="terminal"] .stat-label,
[data-theme="terminal"] .contact-heading,
[data-theme="terminal"] .contact-link,
[data-theme="terminal"] .sidebar-name,
[data-theme="terminal"] .sidebar-copy,
[data-theme="terminal"] .terminal-hint,
[data-theme="terminal"] .theme-btn,
[data-theme="terminal"] .lang-btn,
[data-theme="terminal"] nav a {
  background: #0A0A0A;
  box-shadow: 4px 0 0 #0A0A0A, -4px 0 0 #0A0A0A;
}

[data-theme="terminal"] .section-label::before,
[data-theme="terminal"] .hero-eyebrow::before { content: '> '; color: var(--accent); }

/* ── MAIN ─────────────────────────────────────────────── */
main {
  grid-column: 2;
  min-width: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ── PAGES ────────────────────────────────────────────── */
.page {
  position: absolute;
  inset: 0;
  padding: 0 8vw 60px 6vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  text-align: right;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity 0.5s cubic-bezier(0.16,1,0.3,1), transform 0.5s cubic-bezier(0.16,1,0.3,1);
}
.page.active { opacity: 1; pointer-events: all; transform: translateY(0); }

/* ── SECTION LABEL ────────────────────────────────────── */
.section-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 48px;
  transition: color var(--transition);
}

/* ── HERO ─────────────────────────────────────────────── */
.hero-eyebrow {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 28px;
  transition: color var(--transition);
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(80px, 11vw, 160px);
  font-weight: 300;
  line-height: 0.9;
  letter-spacing: -0.03em;
  margin-bottom: 48px;
}
[data-theme="terminal"] .hero-title { letter-spacing: -0.01em; }

.typed-cursor {
  display: inline-block;
  width: 3px;
  background: var(--accent);
  margin-left: 4px;
  animation: blink 1s step-end infinite;
  vertical-align: baseline;
  height: 0.8em;
  position: relative;
  top: 0.05em;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.hero-bio {
  max-width: 520px;
  font-size: 16px;
  font-weight: 300;
  color: var(--fg-muted);
  line-height: 1.9;
  transition: color var(--transition);
  text-align: right;
}
.hero-bio strong { color: var(--fg); font-weight: 400; }

/* ── PROJECTS ─────────────────────────────────────────── */
#page-projects, #page-tools {
  justify-content: flex-start;
  padding-top: 60px;
  overflow-y: auto;
}

#page-projects .section-label,
#page-tools .section-label { margin-bottom: 24px; }

#page-projects .project-item,
#page-tools .project-item { padding: 20px 0; }

#page-projects .project-name,
#page-tools .project-name { font-size: clamp(20px, 2.5vw, 34px); }

.project-list { display: flex; flex-direction: column; width: 100%; }

.project-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 24px;
  padding: 32px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
  position: relative;
  overflow: hidden;
  direction: rtl;
}

.project-item::after {
  content: '';
  position: absolute;
  right: 0; top: 0;
  width: 2px; height: 100%;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
}
.project-item:hover::after { transform: scaleY(1); }
.project-item:hover .project-name { transform: translateX(-12px); }

.project-content { text-align: right; direction: ltr; }

.project-name {
  font-family: var(--serif);
  font-size: clamp(28px, 3.5vw, 48px);
  font-weight: 300;
  letter-spacing: -0.01em;
  transition: color 0.25s ease, transform 0.3s cubic-bezier(0.16,1,0.3,1);
  color: var(--fg);
}

.project-name a { color: inherit; text-decoration: none; transition: color 0.2s ease; }
.project-name a:hover { color: var(--accent); }

.project-desc {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 8px;
  font-weight: 300;
  transition: color var(--transition);
  line-height: 1.7;
}

.project-meta {
  text-align: left;
  flex-shrink: 0;
  direction: ltr;
  width: auto;
  min-width: 100px;
}

.project-date {
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: 300;
  letter-spacing: 0.04em;
  transition: color var(--transition);
  margin-bottom: 10px;
}

.project-tags {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  column-gap: 8px;
  max-height: 112px;
}

.tag {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  padding: 3px 6px;
  border-radius: var(--radius);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  display: inline-block;
  width: fit-content;
}

[data-theme="dark"] .tag { background: #0A0A0A; border-color: rgba(255,255,255,0.25); color: #8A8A8A; }
[data-theme="light"] .tag { background: #F7F6F2; border-color: rgba(0,0,0,0.25); color: #666660; }
[data-theme="terminal"] .tag { color: var(--fg-muted); border-color: rgba(57,255,20,0.35); }

.project-item:hover .tag { color: var(--accent); border-color: var(--accent); }

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
  letter-spacing: 0.04em;
}
.project-links a {
  display: inline-block;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
[data-theme="dark"] .project-links a { background: #0A0A0A; border-color: rgba(255,255,255,0.25); }
[data-theme="light"] .project-links a { background: #F7F6F2; border-color: rgba(0,0,0,0.25); }
[data-theme="terminal"] .project-links a { border-color: rgba(57,255,20,0.35); }
.project-links a:hover { color: var(--accent); border-color: var(--accent); }

/* ── ABOUT ────────────────────────────────────────────── */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; width: 100%; }

.about-text {
  font-size: 16px;
  font-weight: 300;
  line-height: 1.9;
  color: var(--fg-muted);
  transition: color var(--transition);
  text-align: right;
}
.about-text p + p { margin-top: 20px; }
.about-text strong { color: var(--fg); font-weight: 400; }

.about-stats { display: flex; flex-direction: column; gap: 32px; align-items: flex-end; }

.stat-number { font-family: var(--serif); font-size: 52px; font-weight: 300; line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-muted); margin-top: 4px; transition: color var(--transition); }

/* ── CONTACT ──────────────────────────────────────────── */
.contact-heading {
  font-family: var(--serif);
  font-size: clamp(48px, 7vw, 92px);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: 56px;
  text-align: right;
}

.contact-links { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-muted);
  padding: 8px 0;
  letter-spacing: 0.04em;
  transition: color 0.2s ease;
}
.contact-link::after { content: '↗'; font-size: 12px; transition: transform 0.2s ease; }
.contact-link:hover { color: var(--fg); }
.contact-link:hover::after { transform: translate(2px, -2px); }

/* ── REVEAL ───────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16,1,0.3,1), transform 0.6s cubic-bezier(0.16,1,0.3,1);
}
.reveal.visible { opacity: 1; transform: none; }
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }

/* ── MOBILE ───────────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 20px; right: 20px;
  z-index: 100;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 8px;
  width: 36px; height: 36px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}
.hamburger span { display: block; width: 16px; height: 1px; background: var(--fg); transition: transform 0.3s ease, opacity 0.3s ease; }
.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 768px) {
  body { overflow: auto; }
  .site-wrap { grid-template-columns: 1fr; height: auto; }
  .sidebar { width: 100%; height: 100vh; transform: translateX(-100%); transition: transform var(--transition), background var(--transition); padding: 80px 32px 48px; background: var(--bg); }
  .sidebar.open { transform: translateX(0); }
  main { grid-column: 1; height: auto; overflow: visible; }
  .page { position: relative; inset: auto; opacity: 1; pointer-events: all; transform: none; min-height: 100vh; padding: 80px 24px 60px; align-items: flex-end; }
  .page:not(.active) { display: none; }
  .hamburger { display: flex; }
  .about-grid { grid-template-columns: 1fr; gap: 40px; }
  .project-item { grid-template-columns: 1fr; direction: ltr; }
  .project-content { text-align: right; }
  .project-meta { text-align: right; width: auto; min-width: 0; }
  .project-tags { flex-direction: row; flex-wrap: wrap; max-height: none; justify-content: flex-end; }
}
