/* =========================================
   Rafael Valnásio · Portfolio · Design System
   ========================================= */

:root {
  /* Colors — Dark first */
  --bg: #0a0b0f;
  --bg-elev: #0f1117;
  --bg-elev-2: #14161f;
  --surface: #14161f;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text: #e6e8ee;
  --text-dim: #a3a8b5;
  --text-mute: #6f7482;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --ok: #22c55e;
  --warn: #f59e0b;

  /* Typography */
  --f-sans: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing */
  --container: 1200px;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  /* Shadows */
  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.35);
  --shadow-2: 0 30px 60px -20px rgba(0,0,0,0.5);
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #fafafa;
  --bg-elev-2: #f4f5f8;
  --surface: #ffffff;
  --border: rgba(10,11,15,0.08);
  --border-strong: rgba(10,11,15,0.16);
  --text: #0b0d12;
  --text-dim: #4a5163;
  --text-mute: #6a7284;
  --accent: #6a3dff;
  --accent-2: #0891b2;
  --shadow-1: 0 1px 0 rgba(0,0,0,0.02), 0 8px 24px rgba(15,23,42,0.06);
  --shadow-2: 0 30px 60px -20px rgba(15,23,42,0.15);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* Utilities */
.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--text-mute); }
.grad {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.eyebrow {
  font-family: var(--f-mono);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  margin: 0 0 12px;
}

/* ---------- NAV ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(160%) blur(10px);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav__inner {
  max-width: var(--container);
  margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.nav__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
.brand__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}
.brand__name .muted { color: var(--text-mute); font-weight: 500; }

.nav__links { display: flex; gap: 22px; }
.nav__links a { font-size: 14px; color: var(--text-dim); transition: color .18s ease; }
.nav__links a:hover { color: var(--text); }
.nav__cta { display: flex; align-items: center; gap: 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  border: 1px solid transparent;
  transition: transform .15s ease, background .18s ease, border-color .18s ease, color .18s ease;
}
.btn--lg { padding: 14px 22px; font-size: 15px; }
.btn--primary {
  background: var(--text); color: var(--bg);
}
.btn--primary:hover { transform: translateY(-1px); }
.btn--secondary {
  background: transparent; color: var(--text);
  border-color: var(--border-strong);
}
.btn--secondary:hover { border-color: var(--text); }
.btn--ghost { background: transparent; color: var(--text-dim); }
.btn--ghost:hover { color: var(--text); background: var(--bg-elev-2); }
.btn--icon { padding: 8px; border-radius: 10px; border: 1px solid var(--border); }

/* ---------- HERO ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 96px 0 72px;
}
.grid-lines {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at top, rgba(0,0,0,0.6), transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at top, rgba(0,0,0,0.6), transparent 70%);
  pointer-events: none;
}
.hero__inner {
  position: relative;
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  grid-template-areas:
    "content profile"
    "terminal terminal";
  gap: 48px 56px;
  align-items: start;
}
.hero__content { grid-area: content; }
.hero__profile { grid-area: profile; align-self: center; }
.hero__terminal { grid-area: terminal; margin-top: 24px; }
.hero .badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  font-size: 12.5px; color: var(--text-dim);
  font-family: var(--f-mono);
  margin-bottom: 22px;
}
.badge__pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 60%, transparent);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 60%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.hero__title {
  font-size: clamp(36px, 5.5vw, 64px);
  line-height: 1.05; letter-spacing: -0.03em;
  font-weight: 800;
  margin: 0 0 20px;
}
.hero__lede {
  font-size: 18px; color: var(--text-dim); max-width: 60ch;
  margin: 0 0 28px;
}
.hero__cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 36px; }
.hero__stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  border-top: 1px solid var(--border); padding-top: 20px; max-width: 640px;
}
.hero__stats > div { display: grid; gap: 4px; }
.hero__stats dt { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-mute); }
.hero__stats dd { margin: 0; font-weight: 600; font-size: 15px; }

/* Portrait */
.hero__profile { display: flex; justify-content: center; }
.portrait {
  position: relative;
  width: min(380px, 92%);
  aspect-ratio: 725 / 791;
}
.portrait__frame {
  position: absolute; inset: 0;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  background: var(--bg-elev-2);
  isolation: isolate;
}
.portrait__frame img {
  width: 100%; height: 100%; object-fit: cover;
  filter: saturate(1.05) contrast(1.02);
  transition: transform .6s ease;
}
.portrait:hover .portrait__frame img { transform: scale(1.03); }
.portrait__frame::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, transparent 70%, rgba(10,11,15,0.35) 100%),
    radial-gradient(120% 60% at 100% 0%, color-mix(in oklab, var(--accent) 14%, transparent), transparent 60%);
  pointer-events: none;
}
.portrait__ring {
  position: absolute; inset: -10px;
  border-radius: 32px;
  border: 1px dashed color-mix(in oklab, var(--accent) 50%, transparent);
  opacity: 0.5;
  pointer-events: none;
  animation: spin 22s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.portrait__glow {
  position: absolute; inset: -30px;
  background:
    radial-gradient(50% 50% at 20% 20%, color-mix(in oklab, var(--accent) 30%, transparent), transparent 60%),
    radial-gradient(50% 50% at 80% 80%, color-mix(in oklab, var(--accent-2) 30%, transparent), transparent 60%);
  filter: blur(30px);
  z-index: -1;
  border-radius: 40px;
}
.portrait__chip {
  position: absolute;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  font-family: var(--f-mono); font-size: 11.5px;
  background: color-mix(in oklab, var(--bg-elev) 80%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-dim);
  white-space: nowrap;
  box-shadow: var(--shadow-1);
}
.portrait__chip--top { top: 14px; left: -18px; }
.portrait__chip--bot { bottom: 18px; right: -22px; }
.portrait__chip .mono { color: var(--text-mute); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--ok {
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--ok) 22%, transparent);
}

/* Terminal */
.hero__terminal {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  transform: translateY(0);
}
.term__bar {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg-elev) 90%, black 5%);
}
.term__bar span {
  width: 12px; height: 12px; border-radius: 50%;
  background: #ff5f57;
}
.term__bar span:nth-child(2) { background: #febc2e; }
.term__bar span:nth-child(3) { background: #28c840; }
.term__bar p {
  margin: 0 auto; font-family: var(--f-mono); font-size: 12px; color: var(--text-mute);
}
.term__body {
  margin: 0; padding: 22px 22px 26px;
  font-family: var(--f-mono); font-size: 13.5px;
  color: var(--text); overflow-x: auto;
  line-height: 1.75;
}
.term__body .c-dim { color: var(--text-mute); }
.term__body .c-key { color: var(--accent-2); }
.term__body .c-str { color: #a5f3b8; }
.term__body .c-ok { color: var(--ok); }

/* ---------- STRIP ---------- */
.strip {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 22px 0;
  background: var(--bg-elev);
}
.strip__label {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-mute); margin: 0 0 12px;
}
.strip__list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 10px 26px;
}
.strip__list li {
  font-family: var(--f-mono); font-size: 13px; color: var(--text-dim);
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg);
}

/* ---------- SECTIONS ---------- */
.section { padding: 96px 0; position: relative; }
.section--alt { background: var(--bg-elev); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section__head { max-width: 720px; margin: 0 0 48px; }
.section__title {
  font-size: clamp(28px, 3.4vw, 42px);
  letter-spacing: -0.02em; line-height: 1.1;
  margin: 0 0 12px; font-weight: 700;
}
.section__sub { color: var(--text-dim); font-size: 17px; margin: 0; }
.two-col {
  display: grid; grid-template-columns: 0.9fr 1.4fr; gap: 56px; align-items: start;
}
.two-col--flex { grid-template-columns: 1fr 1fr; gap: 64px; }
.col { min-width: 0; }
.lede { font-size: 17px; color: var(--text); margin: 0 0 16px; }
.about__pills {
  list-style: none; padding: 0; margin: 24px 0 0;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.about__pills li {
  font-family: var(--f-mono); font-size: 12.5px;
  padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 999px;
  color: var(--text-dim); background: var(--bg);
}

/* ---------- SKILLS GRID ---------- */
.skills-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.skill-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.skill-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.skill-card header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.skill-card__icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 30%, transparent), color-mix(in oklab, var(--accent-2) 30%, transparent));
  color: var(--text); font-family: var(--f-mono); font-size: 14px;
  border: 1px solid var(--border-strong);
}
.skill-card h3 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }

/* Badges */
.badges { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.badges li {
  font-family: var(--f-mono); font-size: 11.5px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
}

/* ---------- TIMELINE ---------- */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 140px; top: 0; bottom: 0;
  width: 1px; background: var(--border);
}
.tl {
  display: grid; grid-template-columns: 140px 1fr; gap: 32px;
  padding: 18px 0 18px 0; position: relative;
}
.tl__meta { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding-top: 4px; }
.tl__date { font-family: var(--f-mono); font-size: 12px; color: var(--text-mute); letter-spacing: 0.06em; }
.tag {
  font-family: var(--f-mono); font-size: 10.5px;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--ok) 40%, transparent);
  background: color-mix(in oklab, var(--ok) 10%, transparent);
  color: var(--ok);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.tl__card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  transition: transform .18s ease, border-color .18s ease;
}
.tl__card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.tl__card::before {
  content: ""; position: absolute; left: -47px; top: 26px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 20%, transparent);
}
.tl__card h3 { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.01em; }
.tl__role { margin: 0 0 8px; color: var(--text-dim); font-family: var(--f-mono); font-size: 12.5px; }
.tl__desc { margin: 0 0 14px; color: var(--text-dim); font-size: 14.5px; }
.tl__pills { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tl__pills li {
  font-family: var(--f-mono); font-size: 11.5px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-elev-2);
  color: var(--text-dim);
}
.tl__card--compact { padding: 18px 22px; }

/* ---------- PROJECTS ---------- */
.projects-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
.project-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease;
  display: flex; flex-direction: column;
}
.project-card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.project-card__head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 6%, transparent), transparent 80%);
}
.chip {
  display: inline-block;
  font-family: var(--f-mono); font-size: 10.5px;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  background: var(--bg);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.project-card h3 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.project-card__body { padding: 18px 20px; display: grid; gap: 10px; font-size: 14px; color: var(--text-dim); }
.project-card__body strong { color: var(--text); font-weight: 600; }
.repo-image-wrapper {
  width: 100%;
  min-height: 180px;
  background-size: cover;
  background-position: center;
  overflow: hidden;
  position: relative;
}
.repo-image {
  width: 100%;
  min-height: 180px;
  height: 180px;
  object-fit: contain;
  display: block;
  border-radius: 0;
}
.fallback-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2.6rem;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.4);
  transition: opacity .2s ease;
  opacity: 0;
  pointer-events: none;
}
.repo-image-wrapper.image-failed .fallback-icon {
  opacity: 1;
}
.repo-card { display: flex; flex-direction: column; transition: transform .2s ease, border-color .2s ease; }
.repo-card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.projects-loading,
.projects-error {
  grid-column: 1 / -1;
  padding: 28px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text-mute);
  text-align: center;
}
.project-card__result {
  margin-top: 6px; padding-top: 12px;
  border-top: 1px dashed var(--border);
  color: var(--text); font-family: var(--f-mono); font-size: 12.5px;
}

/* ---------- EDU / CERTS ---------- */
.edu-list, .cert-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.edu-list li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--surface);
}
.edu-list h3 { margin: 0 0 4px; font-size: 15px; letter-spacing: -0.01em; }
.edu-list p { margin: 0; font-size: 13.5px; }
.cert-list li {
  display: grid; grid-template-columns: 60px 1fr; gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}
.cert__year { font-family: var(--f-mono); color: var(--text-mute); font-size: 12.5px; }

/* ---------- CONTACT ---------- */
.section--contact { padding: 96px 0 96px; }
.contact {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: end;
  padding: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(600px 200px at 0% 0%, color-mix(in oklab, var(--accent) 12%, transparent), transparent 60%),
    radial-gradient(500px 200px at 100% 100%, color-mix(in oklab, var(--accent-2) 12%, transparent), transparent 60%),
    var(--surface);
  box-shadow: var(--shadow-2);
}
.contact__list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.contact__list li {
  display: grid; grid-template-columns: 92px 1fr; gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev-2);
  font-size: 14.5px;
}
.contact__label {
  font-family: var(--f-mono); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-mute);
}
.contact__list a { color: var(--text); border-bottom: 1px dashed var(--border-strong); }
.contact__list a:hover { color: var(--accent-2); border-color: var(--accent-2); }

/* ---------- FOOTER ---------- */
.footer { border-top: 1px solid var(--border); padding: 24px 0; }
.footer__inner { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text-dim); }

/* ---------- REVEAL ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
  .hero__inner {
    grid-template-columns: 1fr;
    grid-template-areas: "content" "profile" "terminal";
    gap: 32px;
  }
  .portrait { width: min(300px, 70%); }
  .portrait__chip--top { top: 8px; left: 0; }
  .portrait__chip--bot { bottom: 10px; right: 0; }
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .two-col--flex { grid-template-columns: 1fr; gap: 32px; }
  .timeline::before { left: 12px; }
  .tl { grid-template-columns: 1fr; gap: 12px; padding-left: 34px; }
  .tl__card::before { left: -28px; top: 24px; }
  .hero__stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .nav__links { display: none; }
  .section { padding: 72px 0; }
  .skills-grid, .projects-grid { grid-template-columns: 1fr; }
  .contact { grid-template-columns: 1fr; padding: 28px; }
  .hero { padding: 72px 0 56px; }
  .hero__title { font-size: clamp(32px, 8vw, 42px); }
  .hero__cta .btn { width: 100%; justify-content: center; }
}

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
