/* =========================================================
   Portfólio — Caio Martins
   Paleta tirada da foto de perfil: calçada, pelo tabby, gravata.
   ========================================================= */

:root {
  /* cores */
  --calcada:  #E6E3DD;   /* fundo — o concreto da foto */
  --papel:    #F4F2EE;   /* superfícies */
  --tinta:    #1B1915;   /* texto principal */
  --fumaca:   #615C54;   /* texto secundário — escurecido até passar AA (5.2:1) */
  --tabby:    #6F5C49;   /* marrom do pelo — bordas e detalhes (5.0:1, também vira texto na tag) */
  --gravata:  #B0342B;   /* o único acento */
  --linha:    #CFCAC1;   /* hairlines */

  /* tipografia */
  --display: "Archivo", system-ui, sans-serif;
  --corpo:   "Source Serif 4", Georgia, serif;
  --mono:    "JetBrains Mono", ui-monospace, monospace;

  /* medidas */
  --rail-w: 19rem;
  --doc-w: 44rem;
  --pad: clamp(1.5rem, 4vw, 3.5rem);
}

[data-theme="dark"] {
  --calcada: #17150F;
  --papel:   #201D17;
  --tinta:   #EFEBE2;
  --fumaca:  #A29B8D;
  --tabby:   #A88E73;
  --gravata: #E2695C;
  --linha:   #353026;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 2rem; }

body {
  margin: 0;
  background: var(--calcada);
  color: var(--tinta);
  font-family: var(--corpo);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem; top: 1rem;
  z-index: 50;
  background: var(--gravata);
  color: #fff;
  padding: .6rem 1rem;
  font-family: var(--mono);
  font-size: .8rem;
}

:focus-visible {
  outline: 2px solid var(--gravata);
  outline-offset: 3px;
}

/* ============ ESTRUTURA ============ */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 5rem);
  max-width: 78rem;
  margin: 0 auto;
  padding: var(--pad);
}

/* ============ SIDEBAR ============ */

.rail__inner {
  position: sticky;
  top: var(--pad);
}

.portrait { margin: 0 0 1.5rem; }

.portrait__frame {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--linha);
  border-radius: 50%;
  background: var(--papel);
}

.portrait__frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 35%;
  display: block;
  filter: saturate(.92);
}

.portrait__fallback { display: none; }

.portrait--empty .portrait__frame img { display: none; }

.portrait--empty .portrait__fallback {
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0;
  padding: 1rem;
  text-align: center;
  font-family: var(--mono);
  font-size: .7rem;
  line-height: 1.7;
  color: var(--fumaca);
  background:
    repeating-linear-gradient(45deg,
      transparent 0 8px,
      color-mix(in srgb, var(--tabby) 12%, transparent) 8px 9px);
}

.portrait--empty .portrait__fallback code {
  color: var(--gravata);
}

.portrait__cap {
  margin-top: .6rem;
  font-family: var(--mono);
  font-size: .68rem;
  line-height: 1.5;
  color: var(--fumaca);
}

.rail__id { margin-bottom: 1.75rem; }

.rail__name {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 112%;
  font-size: 1.4rem;
  letter-spacing: -.015em;
}

.rail__role {
  margin: .15rem 0 0;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--fumaca);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--linha);
  border-bottom: 1px solid var(--linha);
}

.nav a {
  font-family: var(--mono);
  font-size: .8rem;
  text-decoration: none;
  color: var(--fumaca);
  padding: .3rem 0 .3rem .9rem;
  position: relative;
  transition: color .18s ease;
}

.nav a::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 4px; height: 1px;
  background: var(--tabby);
  transform: translateY(-50%);
  transition: width .18s ease, background .18s ease;
}

.nav a:hover,
.nav a.is-active { color: var(--tinta); }

.nav a:hover::before,
.nav a.is-active::before { width: 10px; background: var(--gravata); }

.rail__links {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  padding: 1.25rem 0;
}

.rail__links a {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--fumaca);
  text-decoration: none;
  border-bottom: 1px solid var(--linha);
  padding-bottom: 2px;
  transition: color .18s ease, border-color .18s ease;
}

.rail__links a:hover { color: var(--gravata); border-color: var(--gravata); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--fumaca);
}

.toggle__dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid var(--tabby);
  background: var(--tinta);
  transition: background .2s ease;
}

[data-theme="dark"] .toggle__dot { background: transparent; }

.toggle:hover { color: var(--tinta); }

/* ============ HERO ============ */

.doc { max-width: var(--doc-w); padding-top: .25rem; }

.lede__eyebrow {
  margin: 0 0 1.5rem;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gravata);
}

.lede__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 118%;
  font-size: clamp(2.4rem, 6.5vw, 3.9rem);
  line-height: .98;
  letter-spacing: -.032em;
}

.lede__title em {
  font-style: normal;
  color: var(--gravata);
}

/* cada linha é uma máscara; o padding evita cortar descendentes */
.linha {
  display: block;
  overflow: hidden;
  padding-bottom: .08em;
  margin-bottom: -.08em;
}

.linha__in { display: block; }

.lede__sub {
  margin: 1.5rem 0 0;
  max-width: 34rem;
  font-size: 1.15rem;
  color: var(--fumaca);
}

/* tabela de spec — a assinatura da página */
.spec {
  position: relative;
  margin: 2.75rem 0 0;
  padding-top: 2px;
}

/* a régua de cima é pseudo-elemento para poder ser traçada na abertura */
.spec::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--tinta);
  transform-origin: left center;
}

.spec__row {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: 1rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--linha);
}

.spec dt {
  font-family: var(--mono);
  font-size: .72rem;
  text-transform: lowercase;
  color: var(--fumaca);
  padding-top: .2rem;
}

.spec dd {
  margin: 0;
  font-size: .98rem;
}

.dot {
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: .5rem;
  border-radius: 50%;
  background: var(--gravata);
  vertical-align: middle;
}

/* ============ SEÇÕES ============ */

.section { padding-top: 5rem; }

.section--last { padding-bottom: 2rem; }

.section__head {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: .75rem;
}

.section__head::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--linha);
  transform-origin: left center;
}

.anchor {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--gravata);
  flex-shrink: 0;
}

.section__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 112%;
  font-size: 1.45rem;
  letter-spacing: -.02em;
}

.prose { margin: 0; }
.prose p { margin: 0 0 1.1rem; max-width: 36rem; }
.prose p:last-child { margin-bottom: 0; }

/* ============ STACKS ============ */

.stack__row {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--linha);
}

.stack__row:last-child { border-bottom: 0; }

.stack__label {
  margin: 0;
  padding-top: .25rem;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--fumaca);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chips li {
  font-family: var(--mono);
  font-size: .74rem;
  padding: .25rem .6rem;
  border: 1px solid var(--linha);
  border-radius: 2px;
  background: var(--papel);
}

.chips--soft li {
  border-style: dashed;
  background: none;
  color: var(--fumaca);
}

.chips--sm li { font-size: .7rem; padding: .2rem .5rem; }

/* ============ PROJETOS ============ */

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.card {
  padding: 1.5rem;
  background: var(--papel);
  border: 1px solid var(--linha);
  border-left: 2px solid var(--tabby);
  border-radius: 3px;
  transition: border-left-color .2s ease, transform .2s ease;
}

.card:hover {
  border-left-color: var(--gravata);
  transform: translateX(2px);
}

.card__top {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .3rem .9rem;
  margin-bottom: .8rem;
}

.card__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 110%;
  font-size: 1.15rem;
  letter-spacing: -.015em;
}

.card__kind {
  margin: 0;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--fumaca);
}

.card__desc { margin: 0 0 1rem; font-size: 1rem; }

.card__idea {
  margin: 0 0 1.1rem;
  padding-left: 1rem;
  border-left: 1px solid var(--linha);
  font-size: .95rem;
  font-style: italic;
  color: var(--fumaca);
}

.card__links {
  display: flex;
  gap: 1.25rem;
  margin: 1rem 0 0;
}

.card__links a {
  font-family: var(--mono);
  font-size: .74rem;
  text-decoration: none;
  color: var(--gravata);
  border-bottom: 1px solid transparent;
  transition: border-color .18s ease;
}

.card__links a:hover { border-bottom-color: var(--gravata); }

/* ============ EXPERIÊNCIA ============ */

.time { list-style: none; margin: 0; padding: 0; }

.time__item {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--linha);
}

.time__item:last-child { border-bottom: 0; }

.time__item.is-placeholder { opacity: .55; }

.time__when {
  margin: 0;
  padding-top: .3rem;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--fumaca);
}

.time__body { min-width: 0; }

.time__what {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 110%;
  font-size: 1.05rem;
  letter-spacing: -.01em;
}

.time__where {
  margin: .1rem 0 .6rem;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--fumaca);
}

.time__desc { margin: 0; font-size: .98rem; }

/* ============ CURSOS ============ */

.courses { list-style: none; margin: 0; padding: 0; }

.course {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .95rem 0;
  border-bottom: 1px solid var(--linha);
}

.course:last-child { border-bottom: 0; }

.course__name {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-stretch: 108%;
  font-size: 1rem;
}

.course__org {
  margin: .1rem 0 0;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--fumaca);
}

.tag {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: .68rem;
  padding: .2rem .55rem;
  border-radius: 2px;
  border: 1px solid var(--linha);
  color: var(--fumaca);
}

.tag--done  { border-color: var(--tabby); color: var(--tabby); }
.tag--doing { border-color: var(--gravata); color: var(--gravata); }

/* ============ CONTATO ============ */

.contact {
  list-style: none;
  margin: 1.75rem 0 0;
  padding: 0;
  border-top: 1px solid var(--linha);
}

.contact li {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 1rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--linha);
}

.contact span {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--fumaca);
}

.contact a {
  text-decoration: none;
  border-bottom: 1px solid var(--linha);
  padding-bottom: 1px;
  width: fit-content;
  transition: border-color .18s ease, color .18s ease;
}

.contact a:hover { color: var(--gravata); border-color: var(--gravata); }

.foot {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--linha);
}

.foot p {
  margin: 0;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--fumaca);
}

/* ============ MOVIMENTO ============
   Regra da casa: todo estado inicial escondido fica sob `html.js`.
   Sem JavaScript, nada some — a página só perde a animação.
   Para desligar tudo, apague este bloco: nenhum layout depende dele.
   ==================================== */

@keyframes surgir {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes subirLinha {
  from { transform: translateY(105%); }
  to   { transform: none; }
}

@keyframes tracar {
  from { transform: scaleX(0); }
  to   { transform: none; }
}

@keyframes pulsar {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gravata) 50%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---- abertura: o documento se monta de cima para baixo ---- */

.js .lede__eyebrow,
.js .lede__sub,
.js .spec__row,
.js .portrait,
.js .rail__id,
.js .nav,
.js .rail__links,
.js .toggle {
  opacity: 0;
  animation: surgir .6s cubic-bezier(.22, 1, .36, 1) forwards;
  animation-delay: var(--atraso, 0s);
}

/* a sidebar entra primeiro, depois o texto */
.js .portrait     { --atraso: .06s; }
.js .rail__id     { --atraso: .14s; }
.js .nav          { --atraso: .22s; }
.js .rail__links  { --atraso: .30s; }
.js .toggle       { --atraso: .36s; }

.js .lede__eyebrow { --atraso: .10s; }
.js .lede__sub     { --atraso: .42s; }

/* o título sobe por linha, atrás de uma máscara */
.js .linha__in {
  transform: translateY(105%);
  animation: subirLinha .75s cubic-bezier(.22, 1, .36, 1) forwards;
  animation-delay: var(--atraso, 0s);
}

.js .linha:nth-child(1) .linha__in { --atraso: .16s; }
.js .linha:nth-child(2) .linha__in { --atraso: .25s; }

/* a régua da tabela é traçada, e só então as linhas aparecem */
.js .spec::before {
  transform: scaleX(0);
  animation: tracar .7s cubic-bezier(.65, 0, .35, 1) forwards;
  animation-delay: .46s;
}

.js .spec__row:nth-child(1) { --atraso: .54s; }
.js .spec__row:nth-child(2) { --atraso: .60s; }
.js .spec__row:nth-child(3) { --atraso: .66s; }
.js .spec__row:nth-child(4) { --atraso: .72s; }
.js .spec__row:nth-child(5) { --atraso: .78s; }

/* ---- rolagem: cada seção repete o mesmo gesto, em miniatura ---- */

.js .section .anchor,
.js .section .section__title { opacity: 0; }

.js .section.is-in .anchor,
.js .section.is-in .section__title {
  animation: surgir .5s cubic-bezier(.22, 1, .36, 1) forwards;
}

.js .section.is-in .section__title { animation-delay: .06s; }

.js .section__head::after { transform: scaleX(0); }

.js .section.is-in .section__head::after {
  animation: tracar .65s cubic-bezier(.65, 0, .35, 1) .12s forwards;
}

/* itens da seção entram em cascata — o índice vem do script */
.js .reveal-item { opacity: 0; }

.js .is-in .reveal-item {
  animation: surgir .55s cubic-bezier(.22, 1, .36, 1) forwards;
  animation-delay: calc(.18s + var(--i, 0) * 55ms);
}

/* ---- o único elemento ambiente: status "aberto a vagas" ---- */

.dot {
  animation: pulsar 2.8s ease-out 1.4s infinite;
}

/* ---- micro-interações ---- */

.chips li {
  transition: transform .18s ease, border-color .18s ease;
}

.chips li:hover {
  transform: translateY(-2px);
  border-color: var(--tabby);
}

.course {
  transition: padding-left .2s ease;
}

.course:hover { padding-left: .4rem; }

.tag { transition: border-color .2s ease, color .2s ease; }

.time__item .time__what { transition: color .2s ease; }
.time__item:hover .time__what { color: var(--gravata); }

/* ============ RESPONSIVO ============ */

@media (max-width: 62rem) {
  .shell {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .rail__inner { position: static; }

  .portrait {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .portrait__cap { margin-top: 0; }

  .nav { flex-direction: row; flex-wrap: wrap; gap: .25rem 1.1rem; }

  .nav a::before { display: none; }

  /* Alvos de toque: 44px é o mínimo recomendado por Apple e Google para o dedo
     acertar sem mira. No desktop o ponteiro é preciso e isso não faz falta —
     por isso a regra vive aqui dentro. */
  .nav a {
    padding-left: 0;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Aqui o padding não serve: ele empurraria o border-bottom (que é o sublinhado
     do link) para longe do texto. A área de toque cresce por um pseudo-elemento
     invisível, sem mexer no visual. */
  .rail__links { gap: 1.5rem .9rem; }

  .rail__links a { position: relative; }

  .rail__links a::after {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 50%;
    height: 44px;
    transform: translateY(-50%);
  }

  .toggle { min-height: 44px; }

  .doc { max-width: none; }
}

@media (max-width: 34rem) {
  .spec__row,
  .stack__row,
  .time__item,
  .contact li {
    grid-template-columns: 1fr;
    gap: .35rem;
  }

  .spec dt, .stack__label, .time__when { padding-top: 0; }

  .course {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;  /* corta o pulso do status */
    transition-duration: .01ms !important;
  }

  /* garante o estado final mesmo se alguma animação não chegar a rodar */
  .js .lede__eyebrow, .js .lede__sub, .js .spec__row, .js .portrait,
  .js .rail__id, .js .nav, .js .rail__links, .js .toggle,
  .js .reveal-item, .js .section .anchor, .js .section .section__title {
    opacity: 1;
  }

  .js .linha__in { transform: none; }
  .js .spec::before, .js .section__head::after { transform: none; }

  .course:hover { padding-left: 0; }
}
