/* Gerado por ci/build.py a partir de src/css/. Edite lá, não aqui. */
@layer tokens, base, layout, components;

/* Fontes e variáveis: cores, famílias tipográficas e medidas usadas pelas outras camadas. */
@layer tokens {
  /* ---- Fontes locais: arquivos .woff2 na pasta fonts/ ---- */
  @font-face {
    font-family: Cinzel;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/cinzel-400.woff2") format("woff2");
  }

  @font-face {
    font-family: Cinzel;
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/fonts/cinzel-500.woff2") format("woff2");
  }

  @font-face {
    font-family: "EB Garamond";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/eb-garamond-400.woff2") format("woff2");
  }

  @font-face {
    font-family: "EB Garamond";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/eb-garamond-400-italic.woff2") format("woff2");
  }

  /* ---- Paleta e tipos herdados da capa do LinkedIn (Versão A) ---- */
  :root {
    --bg: #14181e;
    --gold: #b8935a; /* títulos grandes e detalhes: contraste 6,24:1 sobre o fundo (AA) */
    --gold-text: #c9a26b; /* dourado em texto pequeno ou corrido e em links: 7,52:1 (AAA) */
    --gold-hi: #e0be8a; /* hover, foco e idioma ativo: 10,09:1 */
    --text: #d3dae2; /* texto: 12,63:1 */
    --muted: #9aa6b2; /* atribuição, rótulos e datas: 7,18:1 */
    --rule: #3a424d; /* filetes, apenas decorativos: 1,75:1 */
    --cinzel: "Cinzel", "Trajan Pro", "Times New Roman", serif;
    --garamond:
      "EB Garamond", garamond, "Adobe Garamond Pro", georgia, "Times New Roman",
      serif;
    --measure: 40rem;
    --edge: clamp(1.25rem, 5vw, 3rem);

    color-scheme: dark;
  }
}

/* Base: elementos HTML, foco, idiomas e utilitários, sem classes de componente. */
@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 clamp(1.1875rem, 1.1rem + 0.4vw, 1.25rem)/1.55 var(--garamond);
  }

  h1,
  h2,
  h3,
  p,
  dl,
  dd,
  ul,
  figure,
  blockquote {
    margin: 0;
    padding: 0;
  }

  h1,
  h2,
  h3 {
    font-weight: 400;
  }

  ul {
    list-style: none;
  }

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

  a {
    color: var(--gold-text);
    text-decoration: underline;
    text-decoration-color: var(--gold);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    overflow-wrap: anywhere;
    transition:
      color 0.15s ease,
      background-color 0.15s ease;
  }

  a:hover {
    color: var(--gold-hi);
  }

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

  main:focus,
  main:focus-visible {
    outline: none;
  }

  /* ---- Idiomas: só aparece o bloco cujo lang coincide com o do elemento html ---- */
  html:not([lang="pt-BR"]) .t[lang="pt-BR"],
  html:not([lang="en"]) .t[lang="en"],
  html:not([lang="es"]) .t[lang="es"],
  html:not([lang="it"]) .t[lang="it"] {
    display: none !important;
  }

  /* ---- Utilitários ---- */
  .vh {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* ---- Título principal: o nome, em letra de livro, como o autor sob a epígrafe ---- */
  h1 {
    color: var(--text);
    font: 400 clamp(2rem, 1.2rem + 2.6vw, 3rem)/1.1 var(--garamond);
    text-wrap: balance;
  }

  /* evita uma palavra sozinha na última linha; navegadores que não conhecem a regra a ignoram */
  p,
  dd {
    text-wrap: pretty;
  }

  @media (prefers-reduced-motion: reduce) {
    a {
      transition: none;
    }
  }

  /* rolagem suave pelo sumário e pelo botão de voltar ao topo */
  @media (prefers-reduced-motion: no-preference) {
    html {
      scroll-behavior: smooth;
    }
  }
}

/* Layout: topo com o seletor de idioma, sumário fixo, hero, seções e rodapé. */
@layer layout {
  .wrap {
    max-width: 64rem;
    margin-inline: auto;
    padding-inline: var(--edge);
  }

  /* ---- Seletor de idioma: links para as páginas de cada idioma ---- */
  .top {
    display: flex;
    justify-content: flex-end;
    min-height: 4.25rem;
    padding-block: 0.75rem;
  }

  .langs ul {
    display: flex;
    gap: 0.15rem;
    margin-right: -0.7rem;
  }

  .langs li {
    display: flex;
    align-items: center;
  }

  .langs a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding-left: 0.16em;
    color: var(--muted);
    font: 400 1.125rem/1 var(--garamond);
    font-variant-caps: all-small-caps;
    letter-spacing: 0.06em;
    text-decoration: none;
  }

  .langs a:hover {
    color: var(--gold-hi);
  }

  html[lang="pt-BR"] .langs [data-lang="pt"],
  html[lang="en"] .langs [data-lang="en"],
  html[lang="es"] .langs [data-lang="es"],
  html[lang="it"] .langs [data-lang="it"] {
    color: var(--gold-hi);
    text-decoration: underline;
    text-decoration-color: var(--gold);
    text-underline-offset: 0.55em;
  }

  /* ---- Sumário fixo: acompanha a rolagem; no celular a faixa de links rola de lado ---- */
  .jump {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-inline: calc(-1 * var(--edge));
    padding: 0.3rem var(--edge) 0.3rem
      calc(var(--edge) + max(0px, 100% - var(--measure)));
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
  }

  .jump ul {
    display: flex;
    flex: 1;
    gap: 1.5rem;
    min-width: 0;
    margin: -4px;
    padding: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .jump ul::-webkit-scrollbar {
    display: none;
  }

  /* stylelint-disable-next-line no-descending-specificity -- .jump a (sumário) e .langs a:hover (topo)
     nunca atingem o mesmo link; qualquer ordem dos dois componentes faria a regra apontar um par. */
  .jump a {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    color: var(--muted);
    font: 400 1.0625rem/1 var(--garamond);
    text-decoration: none;
    white-space: nowrap;
  }

  .jump a:hover,
  .jump a[aria-current] {
    color: var(--gold-hi);
  }

  .jump a[aria-current] {
    text-decoration: underline;
    text-decoration-color: var(--gold);
    text-underline-offset: 0.55em;
  }

  .jump .cv {
    flex: none;
    min-height: 2.25rem;
    padding: 0 1rem;
    border: 1px solid var(--gold);
    color: var(--gold-hi);
  }

  .jump .cv:hover {
    background: var(--gold);
    color: var(--bg);
  }

  /* celular: a borda direita da faixa esmaece, sinal de que há mais links ao rolar */
  @media (max-width: 47.99rem) {
    .jump ul {
      gap: 1.15rem;
      -webkit-mask-image: linear-gradient(
        to right,
        #000 calc(100% - 2.5rem),
        transparent
      );
      mask-image: linear-gradient(
        to right,
        #000 calc(100% - 2.5rem),
        transparent
      );
    }
  }

  /* ---- Hero: o lema como inscrição, alinhado à direita, como na capa; é a única nota alta da página ---- */
  .hero {
    padding-block: clamp(2.5rem, 9vh, 5.5rem) clamp(2rem, 6vh, 3.5rem);
    text-align: right;
  }

  /* margens negativas: anulam o espaço que o letter-spacing deixa depois da última letra */
  .motto blockquote p {
    margin-right: -0.06em;
    color: var(--gold);
    font: 400 clamp(2rem, 0.9rem + 4.6vw, 4.75rem)/1.05 var(--cinzel);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .motto blockquote span {
    white-space: nowrap;
  }

  /* duas linhas fixas, como numa lápide; o ponto romano (interpunct) separa as palavras
     da primeira e não é lido pelos leitores de tela */
  .motto blockquote span:first-child::after {
    content: "\00B7";
    content: "\00B7" / "";
    margin-inline: 0.12em -0.2em;
  }

  .motto blockquote span:last-child {
    display: block;
  }

  .motto .tr {
    margin-top: 0.8em;
    font-size: clamp(1.125rem, 1rem + 0.5vw, 1.4rem);
    font-style: italic;
    line-height: 1.25;
    text-wrap: balance;
  }

  .motto figcaption {
    margin: 0.5rem -0.18em 0 0;
    color: var(--muted);
    font: 400 0.8125rem/1.5 var(--cinzel);
    letter-spacing: 0.18em;
    text-transform: uppercase;
  }

  .motto::after {
    content: "";
    display: block;
    width: 5rem;
    height: 1px;
    margin: 1.75rem 0 0 auto;
    background: var(--gold);
  }

  /* ---- Corpo: coluna ancorada na mesma margem direita do hero ---- */
  .sec {
    max-width: var(--measure);
    margin-left: auto;
    scroll-margin-top: 4.5rem; /* ao vir do sumário, o título da seção fica abaixo do sumário fixo */
  }

  .sec + .sec {
    margin-top: clamp(3.25rem, 7vw, 5rem);
  }

  .sec h2 {
    position: relative;
    margin-bottom: 1.1rem;
    padding-top: 1.05rem;
    color: var(--gold-text);
    font: 400 1rem/1.45 var(--cinzel);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-wrap: balance;
  }

  .sec h2::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 3.5rem;
    height: 1px;
    background: var(--rule);
  }

  .body > * + * {
    margin-top: 1rem;
  }

  .foot {
    margin-top: clamp(4rem, 9vw, 6.5rem);
    padding-block: 1.5rem 5rem;
    border-top: 1px solid var(--rule);
    color: var(--muted);
    font-size: 0.875em;
    text-align: right;
  }

  /* colofão: a fórmula latina que fecha a página, como o lema a abre; discreto, em itálico */
  .foot .colophon {
    margin-bottom: 0.75rem;
    font-size: 1.0625rem;
    font-style: italic;
  }

  /* telas largas: os títulos das seções pendem para a margem livre, alinhados à direita */
  @media (min-width: 62rem) {
    .sec {
      display: grid;
      grid-template-columns: minmax(0, 1fr) var(--measure);
      column-gap: 3rem;
      align-items: baseline;
      max-width: none;
      margin-left: 0;
    }

    .sec h2 {
      margin: 0 -0.16em 0 0;
      text-align: right;
    }

    .sec h2::before {
      left: auto;
      right: 0.16em;
    }

    .sec .body {
      grid-column: 2;
    }
  }
}

/* Componentes: link de pular, apresentação, botões, fichas, projetos, copiar e-mail, voltar ao topo,
   animações e impressão. A impressão fica por último: é a camada mais forte. */
@layer components {
  .skip {
    position: absolute;
    top: -5rem;
    left: var(--edge);
    z-index: 1;
    padding: 0.7rem 1rem;
    background: var(--gold);
    color: var(--bg);
    font: 400 1.0625rem/1.2 var(--garamond);
    text-decoration: none;
  }

  .skip:hover {
    color: var(--bg);
  }

  .skip:focus {
    top: 0.75rem;
  }

  /* ofícios sob o nome, em itálico, separados por vírgula como numa frase */
  .intro .craft {
    margin-top: 0.35rem;
    color: var(--gold-text);
    font: italic 400 clamp(1.125rem, 1rem + 0.4vw, 1.3rem)/1.5 var(--garamond);
  }

  .craft ul {
    display: flex;
    flex-wrap: wrap;
    column-gap: 0.3em;
  }

  .craft li {
    white-space: nowrap;
  }

  .craft li:not(:last-child)::after {
    content: ",";
  }

  .intro .glance {
    margin-top: 1.5rem;
  }

  .aside {
    font-style: italic;
  }

  .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.75rem;
    margin-top: 1.75rem;
  }

  .btn {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--gold);
    color: var(--gold-hi);
    font: 400 1.0625rem/1.3 var(--garamond);
    text-decoration: none;
  }

  .btn:hover {
    background: var(--gold);
    color: var(--bg);
  }

  .entry + .entry {
    margin-top: 2.4rem;
  }

  .entry h3 {
    font-size: 1.22em;
    line-height: 1.25;
    text-wrap: balance;
  }

  .meta {
    margin-top: 0.15rem;
    color: var(--muted);
    font-style: italic;
  }

  .facts {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .entry p:not(.meta),
  .entry .facts {
    margin-top: 0.8rem;
  }

  .facts dt {
    color: var(--muted);
    font-style: italic;
  }

  .facts dd + dt {
    margin-top: 0.7rem;
  }

  /* pares curtos (idiomas): rótulo e valor lado a lado também no celular */
  .facts.pair {
    grid-template-columns: 7.5rem minmax(0, 1fr);
    gap: 0.35rem 1.25rem;
  }

  .facts.pair dd + dt {
    margin-top: 0;
  }

  .note {
    color: var(--muted);
    font-style: italic;
  }

  /* detalhes dos projetos: abrem no próprio lugar */
  .entry details {
    margin-top: 0.6rem;
  }

  .entry summary {
    display: inline-flex;
    align-items: center;
    gap: 0.6em;
    min-height: 2.75rem;
    cursor: pointer;
    list-style: none;
    color: var(--gold-text);
    font: 400 1.0625rem/1 var(--garamond);
  }

  .entry summary::-webkit-details-marker {
    display: none;
  }

  .entry summary::before {
    content: "+";
    content: "+" / "";
    width: 0.7em;
    font-size: 1.15rem;
    letter-spacing: 0;
  }

  .entry details[open] > summary::before {
    content: "\2212";
    content: "\2212" / "";
  }

  .entry summary:hover {
    color: var(--gold-hi);
  }

  .entry details[open] .see,
  .entry details:not([open]) .hide {
    display: none;
  }

  /* copiar o e-mail: útil para quem usa webmail e não tem programa de e-mail configurado */
  .mail {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 0.9rem;
  }

  .copy {
    min-height: 2.25rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--gold-text);
    font: italic 400 1.0625rem/1 var(--garamond);
    cursor: pointer;
  }

  .copy:hover {
    color: var(--gold-hi);
  }

  .copy .ok,
  .copy.done .idle {
    display: none;
  }

  .copy.done .ok {
    display: inline;
  }

  .entry details .facts {
    margin-top: 0.3rem;
  }

  /* botão de voltar ao topo: aparece quando a apresentação sai da tela (o script põe a classe "on") */
  .totop {
    position: fixed;
    right: var(--edge);
    bottom: 1.25rem;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--gold);
    border-radius: 50%;
    background: var(--bg);
    color: var(--gold-hi);
    font: 400 1.125rem/1 var(--garamond);
    text-decoration: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(0.5rem);
    transition:
      opacity 0.25s ease,
      transform 0.25s ease,
      visibility 0s linear 0.25s,
      background-color 0.15s ease,
      color 0.15s ease;
  }

  .totop.on:not(.down) {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition:
      opacity 0.25s ease,
      transform 0.25s ease,
      visibility 0s,
      background-color 0.15s ease,
      color 0.15s ease;
  }

  .totop:hover {
    background: var(--gold);
    color: var(--bg);
  }

  /* ---- Página de agradecimento (Gratiarum actio): o título é a inscrição da página ---- */
  .thanks h1 {
    margin-right: -0.06em;
    color: var(--gold);
    font: 400 clamp(1.875rem, 1rem + 3.6vw, 3.5rem)/1.1 var(--cinzel);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .epigraph {
    margin: 1.5rem 0 0 auto;
    max-width: 32rem;
  }

  /* o parágrafo da citação herda a letra; a quebra das linhas fica a de todo parágrafo (pretty) */
  .epigraph blockquote {
    font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.6rem);
    font-style: italic;
    line-height: 1.3;
  }

  .epigraph .tr {
    margin-top: 0.6em;
    text-wrap: balance;
  }

  .epigraph figcaption {
    margin-top: 0.5rem;
    color: var(--muted);
    font-size: 1rem;
  }

  /* o mesmo filete dourado que fecha o lema, sob a epígrafe */
  .epigraph::after {
    content: "";
    display: block;
    width: 5rem;
    height: 1px;
    margin: 1.75rem 0 0 auto;
    background: var(--gold);
  }

  /* margem negativa: anula o espaço que o letter-spacing deixa depois da última letra */
  .thanks .laus {
    margin: 2rem -0.16em 0 0;
    color: var(--gold-text);
    font: 400 1rem/1.45 var(--cinzel);
    letter-spacing: 0.16em;
    text-align: right;
    text-transform: uppercase;
  }

  .back {
    margin-top: clamp(3rem, 7vw, 4.5rem);
  }

  @media (min-width: 36rem) {
    .facts,
    .facts.pair {
      grid-template-columns: 9rem minmax(0, 1fr);
      gap: 0.6rem 1.5rem;
    }

    .facts dd + dt {
      margin-top: 0;
    }
  }

  /* entrada, uma vez: o filete sob o lema se desenha e a apresentação surge do quase transparente */
  @media (prefers-reduced-motion: no-preference) {
    .motto::after {
      animation: draw 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    }

    .intro .body > * {
      animation: rise 0.45s ease-out both;
    }
  }

  /* página de agradecimento: a mesma entrada, mais lenta e em ordem de leitura, como uma procissão:
     o título, a epígrafe, o filete que se desenha, a prosa e, por fim, Laus Deo. O topo, o link de
     volta e o rodapé não se movem: o que se usa fica pronto desde o início */
  @media (prefers-reduced-motion: no-preference) {
    .thanks h1 {
      animation: rise 1s ease-out both;
    }

    .epigraph {
      animation: rise 1s ease-out 0.25s both;
    }

    .epigraph::after {
      animation: draw 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.7s both;
    }

    .thanks .body > p {
      animation: rise 1s ease-out 0.9s both;
    }

    .thanks .body > .laus {
      animation-delay: 1.3s;
    }
  }

  /* detalhes dos projetos abrem com movimento */
  @media (prefers-reduced-motion: no-preference) {
    .entry details[open] > .facts {
      animation: unfold 0.3s ease-out;
    }
  }

  /* onde o navegador permite, a altura também se abre e se fecha suavemente */
  @media (prefers-reduced-motion: no-preference) {
    @supports (interpolate-size: allow-keywords) {
      :root {
        interpolate-size: allow-keywords;
      }

      .entry details::details-content {
        block-size: 0;
        overflow: hidden;
        transition:
          block-size 0.3s ease,
          content-visibility 0.3s allow-discrete;
      }

      .entry details[open]::details-content {
        block-size: auto;
      }
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .totop {
      transition: none;
    }
  }

  @keyframes unfold {
    from {
      opacity: 0;
      transform: translateY(-0.4rem);
    }
  }

  @keyframes draw {
    from {
      transform: scaleX(0);
    }
  }

  @keyframes rise {
    from {
      opacity: 0.2;
    }
  }

  @media print {
    :root {
      --bg: #fff;
      --text: #111;
      --muted: #444;
      --gold: #6b5326;
      --gold-text: #6b5326;
      --gold-hi: #6b5326;
      --rule: #bbb;

      color-scheme: light;
    }

    .top,
    .skip,
    .jump,
    .totop,
    .entry summary,
    .copy {
      display: none;
    }

    .entry details::details-content {
      block-size: auto;
      content-visibility: visible;
    }

    .hero {
      padding-block: 1rem 2rem;
    }

    .motto blockquote p {
      font-size: 2rem;
    }
  }
}
