:root {
  --bg: #1b1b1a;
  --fg: #e9e5dc;
  --muted: #9a958b;
  --dim: #5f5c56;
  --line: #45433f;
  --accent: #e0985a;
  --card: rgba(27, 27, 26, 0.72);
  /* Recuo esquerdo do conteúdo: cresce com a tela, mantendo a coluna (820 px)
     centralizada em telas largas ou com zoom reduzido */
  --gutter: max(16px, calc((100vw - 1100px) / 2 + 140px));
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f1ede4;
  --fg: #25231f;
  --muted: #6b665c;
  --dim: #a59f92;
  --line: #c9c2b4;
  --accent: #b55e27;
  --card: rgba(241, 237, 228, 0.78);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.75 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.3s, color 0.3s;
}

#pond {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

main, .footer { position: relative; z-index: 1; }

/* Texto legível mesmo com carpa passando por baixo */
main p, main li, main h2, main h3, .footer { text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg); }

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: color 0.2s, border-color 0.2s;
}
a:hover { color: var(--accent); border-color: var(--accent); }

::selection { background: var(--accent); color: var(--bg); }

/* ── barra superior ─────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 28px 16px 28px;
  background: linear-gradient(var(--bg) 62%, transparent);
}
#nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 36px; }
#nav a {
  position: relative;
  display: inline-block;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  /* leve "quique" ao crescer */
  transition: color 0.3s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#nav a.active, #nav a:hover, #nav a:focus-visible { color: var(--fg); }
#nav a:hover, #nav a:focus-visible { transform: scale(1.12); }

/* Ondinha: as letras sobem uma a uma, como uma onda passando pela palavra */
#nav .wave > span { display: inline-block; }
#nav a:hover .wave > span, #nav a:focus-visible .wave > span {
  animation: nav-wave 0.55s ease-in-out both;
  animation-delay: calc(var(--i) * 40ms);
}
@keyframes nav-wave {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-3px); }
}

/* Linha fina que se abre do centro */
#nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.35s ease;
}
#nav a:hover::after, #nav a:focus-visible::after { transform: scaleX(1); }

@media (prefers-reduced-motion: reduce) {
  #nav a, #nav a::after { transition: color 0.3s ease; }
  #nav a:hover .wave > span, #nav a:focus-visible .wave > span { animation: none; }
}

.theme-toggle, .counter button, .lang-toggle {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.theme-toggle { margin-left: 28px; line-height: 0; padding: 6px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle svg { display: block; }

/* Troca de tema: o novo tema é revelado por um círculo (animado em main.js) */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.theme-switching body, .theme-switching body * { transition: none !important; }
.theme-toggle:hover { color: var(--fg); }

/* Idioma: "pt / en" no canto superior esquerdo; o idioma atual fica aceso */
.lang-toggle {
  position: fixed;
  top: 30px;
  left: clamp(16px, 8vw, 160px);
  z-index: 11;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 12px;
  letter-spacing: 0.04em;
  border: 1px dashed var(--line);
  transition: border-color 0.25s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lang-toggle span { color: var(--dim); transition: color 0.3s; }
.lang-toggle span.on { color: var(--accent); }
.lang-toggle .sep { color: var(--line); }
.lang-toggle:hover, .lang-toggle:focus-visible { border-color: var(--accent); transform: scale(1.08); }
.lang-toggle:hover span:not(.on):not(.sep) { color: var(--fg); }
.lang-toggle:active { transform: scale(0.95); }

/* Some e volta ao trocar de idioma */
main, .footer { transition: opacity 0.22s ease, filter 0.22s ease; }
.lang-out { opacity: 0; filter: blur(3px); }

.counter {
  position: fixed;
  top: 30px;
  right: clamp(16px, 8vw, 160px);
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 12px;
  line-height: 1.6;
  color: var(--dim);
}
.counter-row { display: flex; align-items: center; gap: 6px; }
.counter-row > span:not(.counter-label) { min-width: 2ch; text-align: center; color: var(--muted); }
.counter-label { width: 7ch; text-align: left; color: var(--dim); }
.counter-spacer { width: 18px; }
.counter button {
  color: var(--dim);
  width: 18px; height: 18px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  border: 1px dashed var(--line);
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.counter button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); transform: scale(1.12); }
.counter button:active:not(:disabled) { transform: scale(0.92); }
.counter button:disabled { opacity: 0.35; cursor: default; }

/* ── hero ───────────────────────────────────────────────────────── */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 120px 16px 18vh var(--gutter); /* o topo reserva espaço para o menu fixo */
  position: relative;
}
.hero-inner { max-width: 820px; }

.tagline {
  color: var(--muted);
  min-height: 3.6em;
  margin: 0 0 3.2em;
  white-space: pre-line;
}
.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: -0.2em;
  background: var(--muted);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hero-body { font-size: 17px; line-height: 1.95; }
.hero-body p { margin: 0; }
.hero-body .socials { margin-top: 1.1em; color: var(--dim); }
.hero-body .socials a { color: var(--muted); }

.scroll-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  border: 0;
  color: var(--dim);
  font-size: 12px;
  animation: bob 3.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translate(-50%, 6px); } }

/* ── seções ─────────────────────────────────────────────────────── */
.section {
  padding: 14vh 16px 4vh var(--gutter);
  max-width: calc(var(--gutter) + 820px);
}
.section-inner { max-width: 820px; }

.section-title {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 2.2em;
  display: flex;
  align-items: center;
  gap: 14px;
}
.section-title .idx { color: var(--accent); }
.section-title::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }

.about p { margin: 0 0 1.2em; }

/* Foto na seção "sobre": moldura tracejada no estilo do resto da página */
.about.has-photo { display: grid; grid-template-columns: 230px 1fr; gap: 40px; align-items: start; }
.portrait { margin: 0; position: sticky; top: 110px; }
.portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 737 / 900;
  object-fit: cover;
  border: 1px dashed var(--line);
  padding: 6px;
  background: var(--card);
  filter: grayscale(0.35) contrast(1.02);
  transition: filter 0.6s ease, border-color 0.3s;
}
.portrait:hover img { filter: none; border-color: var(--accent); }
.portrait figcaption { margin-top: 8px; font-size: 11px; color: var(--dim); text-shadow: 0 0 6px var(--bg); }

.highlights { margin: 10px 0 0; padding: 0; list-style: none; }
.highlights li { position: relative; padding-left: 18px; margin: 4px 0; color: var(--muted); font-size: 14px; line-height: 1.65; text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg); }
.highlights li::before { content: "›"; position: absolute; left: 2px; color: var(--accent); }

.subhead { margin: 2.6em 0 0.8em; font-size: 13px; font-weight: 500; color: var(--muted); }
.subhead::before { content: "~/ "; color: var(--accent); }
.courses { margin: 0; padding: 0; list-style: none; }
.courses li { padding: 6px 0; border-bottom: 1px dashed var(--line); color: var(--muted); font-size: 14px; }
.courses li strong { color: var(--fg); font-weight: 500; }
.courses li:last-child { border-bottom: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 4px 24px;
  padding: 18px 0;
  border-bottom: 1px dashed var(--line);
}
.timeline > li:last-child { border-bottom: 0; }
.timeline .period { color: var(--dim); font-size: 13px; padding-top: 2px; }
.timeline h3 { margin: 0; font-size: 15px; font-weight: 500; }
.timeline .company { color: var(--muted); }
.timeline p { margin: 6px 0 0; color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding: 0; list-style: none; }
.tags li {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 1px 8px;
  text-shadow: none;
}

.projects { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.project {
  border: 1px dashed var(--line);
  background: var(--card);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  padding: 18px 20px;
  transition: border-color 0.2s, transform 0.2s;
}
.project:hover { border-color: var(--accent); transform: translateY(-2px); }
.project h3 { margin: 0 0 6px; font-size: 15px; font-weight: 500; }
.project h3::before { content: "> "; color: var(--accent); }
.project p { margin: 0; color: var(--muted); font-size: 14px; }
.project { display: flex; flex-direction: column; }
.project .tags { margin-bottom: 4px; }
.project-foot { margin-top: auto; padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.project .links { font-size: 13px; display: flex; gap: 16px; }
.project.has-details { cursor: pointer; }
.project.is-source { visibility: hidden; }

/* Botão ⤢ no canto inferior direito: as setas se afastam no hover */
.expand {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  padding: 0;
  background: none;
  border: 1px dashed var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.expand svg * { transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.project:hover .expand, .expand:focus-visible { color: var(--accent); border-color: var(--accent); transform: scale(1.08); }
.project:hover .expand .arrow-a, .expand:focus-visible .arrow-a { transform: translate(1.5px, -1.5px); }
.project:hover .expand .arrow-b, .expand:focus-visible .arrow-b { transform: translate(-1.5px, 1.5px); }

/* ── painel de detalhes ─────────────────────────────────────────── */
html.d-lock { overflow: hidden; }
html.d-lock body { padding-right: var(--scrollbar, 0px); }

.d-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px 20px;
}
.d-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(6px) saturate(0.9);
  -webkit-backdrop-filter: blur(6px) saturate(0.9);
}
.d-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(90vh, 960px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px dashed var(--accent);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
  transform-origin: 0 0; /* necessário para a animação FLIP */
}
.d-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 40px 44px 44px; }
.d-close {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 2;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--bg);
  border: 1px dashed var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.d-close:hover, .d-close:focus-visible { color: var(--accent); border-color: var(--accent); transform: rotate(90deg); }

/* Cascata: cada bloco do conteúdo sobe e aparece um depois do outro */
.d-content > * { opacity: 0; transform: translateY(14px); }
.is-open .d-content > * {
  opacity: 1;
  transform: none;
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 0.9, 0.25, 1);
  transition-delay: calc(var(--k, 0) * 70ms);
}

.d-kicker { margin: 0 0 4px; font-size: 12px; color: var(--accent); }
.d-kicker::before { content: "~/ "; }
.d-head h2 { margin: 0 0 12px; font-size: clamp(20px, 3vw, 26px); font-weight: 500; }
.d-head .tags { margin: 0 0 14px; }
.d-links { display: flex; gap: 20px; font-size: 13px; }
.d-summary { margin: 28px 0 8px; }
.d-summary p { margin: 0 0 1em; line-height: 1.8; }
.d-content code { font-size: 0.92em; color: var(--accent); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; margin: 24px 0; background: var(--line); border: 1px solid var(--line); }
.facts div { background: var(--bg); padding: 10px 14px; }
.facts dt { font-size: 11px; color: var(--dim); }
.facts dd { margin: 2px 0 0; font-size: 13px; }

.d-section { margin-top: 32px; }
.d-section h3 { margin: 0 0 12px; font-size: 13px; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.d-section h3::before { content: "#"; color: var(--accent); }
.d-section h3::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.d-section ul { margin: 0; padding: 0; list-style: none; }
.d-section li { position: relative; padding-left: 18px; margin: 8px 0; font-size: 14px; line-height: 1.7; color: var(--muted); }
.d-section li::before { content: "›"; position: absolute; left: 2px; color: var(--accent); }
.d-section li strong { color: var(--fg); font-weight: 500; }

.block, .chart { margin: 28px 0 0; }
.block figcaption, .chart figcaption { font-size: 11px; color: var(--dim); margin-bottom: 8px; }
.block figcaption::before, .chart figcaption::before { content: "── "; }
.block pre {
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  font: 12.5px/1.5 "JetBrains Mono", ui-monospace, monospace;
  color: var(--fg);
  background: var(--card);
  border: 1px dashed var(--line);
}

/* Gráfico de barras: crescem em sequência quando o painel abre */
.bar-row { display: grid; grid-template-columns: 150px 1fr 64px 64px; align-items: center; gap: 12px; margin: 8px 0; font-size: 12.5px; }
.bar-label { color: var(--muted); }
.bar-track { height: 12px; background: color-mix(in srgb, var(--line) 45%, transparent); }
.bar {
  display: block;
  height: 100%;
  width: 0;
  background: var(--dim);
  transition: width 1s cubic-bezier(0.2, 0.9, 0.25, 1);
  transition-delay: calc(var(--i) * 110ms + 350ms);
}
.is-open .bar { width: var(--w); }
.bar-row.hl .bar { background: var(--accent); }
.bar-row.hl .bar-label, .bar-row.hl .bar-value { color: var(--fg); }
.bar-value { text-align: right; }
.bar-note { color: var(--dim); text-align: right; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.gallery figure { margin: 0; }
.gallery figure.wide { grid-column: 1 / -1; }
/* Prints de computador: 2 por linha (o "wide" continua ocupando a largura toda) */
.gallery.is-desktop { grid-template-columns: repeat(2, 1fr); }
.gallery figcaption { margin-top: 6px; font-size: 11px; line-height: 1.5; color: var(--dim); }
.shot {
  display: block;
  width: 100%;
  padding: 4px;
  background: var(--card);
  border: 1px dashed var(--line);
  cursor: zoom-in;
  transition: border-color 0.25s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.shot:hover, .shot:focus-visible { border-color: var(--accent); transform: translateY(-3px); }
.shot img { display: block; width: 100%; height: auto; }
.d-note { margin: 12px 0 0; font-size: 11px; color: var(--dim); }

/* Print ampliado */
.d-viewer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  cursor: zoom-out;
}
.d-viewer img { max-width: min(92vw, 1400px); max-height: 86vh; border: 1px dashed var(--line); transform-origin: 0 0; }
.d-viewer-hint { position: absolute; bottom: 18px; font-size: 11px; color: var(--dim); }

@media (max-width: 640px) {
  .d-overlay { padding: 0; }
  .d-panel { width: 100%; height: 100vh; height: 100dvh; max-height: none; border: 0; }
  .d-scroll { padding: 56px 18px 32px; }
  .bar-row { grid-template-columns: 1fr 52px; gap: 4px 10px; }
  .bar-label { grid-column: 1 / -1; }
  .bar-note { display: none; }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .gallery.is-desktop { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .d-content > *, .is-open .d-content > * { opacity: 1; transform: none; transition: none; }
  .bar, .is-open .bar { width: var(--w); transition: none; }
}

.skills { display: grid; gap: 10px; margin: 0; }
.skills div { display: grid; grid-template-columns: 150px 1fr; gap: 24px; }
.skills dt { color: var(--dim); }
.skills dd { margin: 0; }

.contact p { margin: 0 0 1em; color: var(--muted); }
.contact .email { font-size: clamp(18px, 3vw, 26px); }

.footer {
  padding: 18vh 16px 40px var(--gutter);
  color: var(--dim);
  font-size: 12px;
}

/* ── animação de entrada ao rolar ───────────────────────────────── */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity 1.1s ease, transform 1.1s ease; transition-delay: var(--d, 0s); }
.reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .cursor, .scroll-hint { animation: none; }
}

/* ── celular ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  body { font-size: 14px; }
  .topbar { padding-top: 18px; justify-content: flex-start; }
  #nav { justify-content: flex-start; gap: 4px 18px; }
  #nav a { font-size: 13px; }
  #nav { flex: 1 1 auto; min-width: 0; }
  .topbar .lang-toggle { margin-left: 10px; padding: 3px 6px; flex-shrink: 0; align-self: flex-start; }
  .topbar .theme-toggle { margin-left: 6px; flex-shrink: 0; align-self: flex-start; }
  .hero-body { font-size: 15px; }
  .timeline > li, .skills div { grid-template-columns: 1fr; gap: 2px; }
  .about.has-photo { grid-template-columns: 1fr; gap: 24px; }
  .portrait { position: static; max-width: 220px; }
}
/* ── zoom e telas intermediárias ────────────────────────────────── */
/* Sem espaço ao lado do menu (zoom ampliado, janelas estreitas): o contador vira um widget no canto de baixo */
@media (max-width: 1180px) {
  .lang-toggle { position: static; order: 2; margin-left: 20px; }
  .theme-toggle { order: 3; }
  .counter {
    top: auto;
    bottom: 16px;
    right: 16px;
    padding: 6px 8px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    border: 1px dashed var(--line);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
}
/* Telas baixas (zoom muito ampliado, celular deitado) */
@media (max-height: 560px) {
  .hero { padding-bottom: 56px; }
  .scroll-hint { display: none; }
  .section { padding-top: 72px; }
}
