/* Estudos de partidas famosas (fase 1.5) — complementa aprenda/post.css (tema escuro do site, mobile primeiro). */

/* a análise abre depois do desafio (D-EST-05): sem JS (ou se o JS não rodar em 10 s) fica tudo à vista */
.js .est-trancado { display: none; }
.js.est-sem-js .est-trancado { display: block; }
/* DES-06: quem chega por link direto (#c-<id>, #comentarios…) já recebe a classe est-link antes da 1ª pintura */
.js.est-link .est-trancado { display: block; }
/* DES-06/TEL-16 (D-EST-76): o que o JS do estudo acrescenta ACIMA de um comentário já tem o lugar guardado desde a 1ª
   pintura — o Chrome pinta o alto da página antes de rodar os scripts e só depois rola até o #c-<id>; cada pixel que
   aparecesse no meio virava salto. Medido a 390 e 1280: desafio +36 px (+65 com toque: a dica "toque…"), controles do
   replay +44 px, caixa de comentário 190 px (com sessão) — e o convite para entrar (sem sessão) ganhou a mesma altura. */
.js .est-fig-desafio > details.ex-solucao:not([hidden]) { margin-bottom: 36px; }
@media (pointer: coarse) { .js .est-fig-desafio > details.ex-solucao:not([hidden]) { margin-bottom: 65px; } }
.js .est-replay-esq > .est-replay-tab:only-child { margin-bottom: 70px; }   /* 26 do figure.diagrama + 44 */
.js #cm-form { min-height: 190px; }
.js.est-sem-js .est-fig-desafio > details.ex-solucao, .js.est-sem-js .est-replay-esq > .est-replay-tab:only-child { margin-bottom: 0; }
.js.est-sem-js #cm-form { min-height: 0; }
/* só o widget do desafio faltou (aprenda.js ou motor.js não carregou): o "Ver resposta" fica o do HTML, sem a reserva */
.js.est-sem-desafio .est-fig-desafio > details.ex-solucao { margin-bottom: 0; }

.estudo-famoso article h2 {
  font-family: 'Playfair Display', 'Playfair Reserva', serif; font-size: 24px; color: var(--accent); margin: 34px 0 12px; line-height: 1.3; scroll-margin-top: 16px;
}
.est-cab { margin-bottom: 18px; }
.est-sobre { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.est-ficha { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 8px; font-size: 14px; }
.est-ficha div { display: flex; gap: 6px; min-width: 0; }
.est-ficha dt { color: var(--text-muted); }
.est-ficha dt::after { content: ':'; }
.est-ficha dd { color: var(--text-light); font-weight: 600; overflow-wrap: anywhere; }

/* desafio */
.est-desafio { scroll-margin-top: 16px; }
.est-fig-desafio { margin-top: 8px; }
.est-semjs { font-size: 14px; color: var(--text-muted); margin: 10px 0 0; text-align: center; }
.est-resultado:empty { display: none; }
.est-resultado { margin: 14px 0 6px; padding: 14px 16px; border-radius: 10px; background: var(--bg-card); border: 1px solid var(--linha); font-size: 15px; }
.est-resultado.ok { border-color: rgba(155,224,155,0.55); }
.est-resultado.erro { border-color: rgba(255,138,138,0.5); }
.est-resultado p { margin: 0 0 8px; }
.est-resultado .est-res-extra { color: var(--text-muted); font-size: 14px; }
.est-res-acoes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* TEL-17: depois de "Ver resposta" pelo teclado o foco vem para o quadro do resultado */
.est-resultado:focus { outline: none; }
.est-resultado:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.est-res-acoes .btn, .est-res-acoes .cta-btn { display: inline-flex; align-items: center; text-decoration: none; margin: 0; }

/* momentos */
.est-nota { font-size: 13px; color: var(--text-muted); }
.est-momento { margin: 26px 0 30px; padding-top: 4px; scroll-margin-top: 16px; }
.est-momento h3 { font-size: 19px; color: var(--text-light); margin-bottom: 4px; }
.est-momento-n { display: block; font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }
.est-momento figure.diagrama { margin: 12px auto 12px; }
.est-avals { display: grid; gap: 4px; margin: 0 auto 14px; max-width: 400px; font-size: 14px; }
.est-avals div { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.est-avals dt { color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.est-avals dt::after { content: ':'; }
.est-avals dd { font-weight: 600; }
.est-av { font-weight: 400; color: var(--text-muted); white-space: nowrap; }
.est-seta { display: inline-block; width: 18px; height: 6px; border-radius: 3px; }
.est-seta.azul { background: #1f5fbf; box-shadow: 0 0 0 1px #8fb4ef; }
.est-seta.verde { background: #15781b; box-shadow: 0 0 0 1px #8fd08f; }

/* gráfico de vantagem (uma série: sem legenda; o título diz o que é) */
.est-grafico { position: relative; margin: 8px 0 6px; }
.est-grafico-svg { display: block; width: 100%; height: auto; touch-action: pan-y; cursor: crosshair; }
.est-grafico figcaption { font-size: 13px; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }
.g-fundo { fill: #232f54; }
.g-brancas { fill: #e8e8e8; fill-opacity: 0.85; }
.g-pretas { fill: #0d1022; fill-opacity: 0.9; }
.g-zero { stroke: #97a6b5; stroke-width: 1; stroke-dasharray: 2 3; }
.g-grade { stroke: rgba(255,255,255,0.08); stroke-width: 1; }
.g-linha { fill: none; stroke: #e2b96f; stroke-width: 2; stroke-linejoin: round; }
.g-momento { fill: #e2b96f; stroke: #1e2a4a; stroke-width: 2; }
.g-desafio { stroke: #9be09b; stroke-width: 2; stroke-dasharray: 5 4; }
.g-rot { fill: #97a6b5; font: 600 12px Inter, system-ui, sans-serif; }
.g-rot-desafio { fill: #9be09b; }
.g-cursor { stroke: #fff; stroke-width: 1.5; pointer-events: none; }
.est-grafico-dica {
  position: absolute; top: -6px; transform: translateY(-100%); background: #0d1022; color: var(--text-light); border: 1px solid var(--linha);
  border-radius: 8px; padding: 4px 10px; font-size: 13px; white-space: nowrap; pointer-events: none; z-index: 3;
}
.est-tabela summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 44px; display: flex; align-items: center; font-size: 15px; }

/* replay */
.est-replay-corpo { display: grid; gap: 12px 24px; }
.est-replay-esq { min-width: 0; }
.est-replay-tab { margin: 0 auto; width: 100%; max-width: 400px; }
.est-replay-tab:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.est-replay-ctl { display: flex; gap: 6px; justify-content: center; margin: 10px auto 0; max-width: 400px; }
.est-replay-ctl .btn { flex: 1 1 0; padding: 0 8px; font-size: 17px; }
.est-replay-ctl .btn:disabled { opacity: 0.4; cursor: not-allowed; }
.est-replay-status { text-align: center; font-size: 14px; color: var(--text-muted); margin: 6px 0 0; min-height: 22px; }
.est-replay-dica { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.est-lances {
  list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 2px 8px;
  font-size: 15px; max-height: 360px; overflow-y: auto; position: relative;
}
.est-lances li { margin: 0; display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.est-n { color: var(--text-muted); min-width: 30px; display: inline-block; font-size: 13px; }
.est-l { font: inherit; color: var(--text-light); background: none; border: 0; border-radius: 6px; padding: 0 6px; min-height: 44px; min-width: 44px; cursor: pointer; text-align: left; }
.est-l:hover { background: rgba(255,255,255,0.06); }
.est-l.momento { color: var(--accent); font-weight: 700; }
.est-l.atual { background: var(--accent); color: var(--bg-dark); }
.est-l:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (min-width: 760px) {
  .est-replay-corpo { grid-template-columns: minmax(0, 400px) minmax(0, 1fr); align-items: start; }
  .est-lances { grid-template-columns: 1fr; max-height: 430px; }
}

/* lição */
.est-licao { background: var(--bg-card); border: 1px solid rgba(226,185,111,0.35); border-radius: 12px; padding: 4px 18px 18px; margin-top: 34px; }
.est-licao h2 { margin-top: 18px !important; }
.est-licao .cta-btn { margin-top: 4px; }
.est-rel { margin: 34px 0 0; }
.est-rel h2 { font-family: 'Playfair Display', 'Playfair Reserva', serif; font-size: 22px; color: var(--accent); margin: 0 0 10px; }
.est-rel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.est-rel a { display: flex; align-items: center; min-height: 44px; padding: 10px 14px; border-radius: 10px; background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06); color: var(--text-light); text-decoration: none; }
.est-rel a:hover, .est-rel a:focus-visible { border-color: rgba(226,185,111,0.5); color: var(--accent); }
.est-todos { margin: 30px 0 0; }
.est-todos a { display: inline-flex; align-items: center; min-height: 44px; }

/* comentários (o bloco #cm-bloco é desenhado por estudos-comentarios.js, igual no servidor e aqui) */
.est-comentarios { margin-top: 34px; scroll-margin-top: 16px; }
.cm-dica { font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }
/* convite para entrar (sem login): a mesma altura da caixa de escrever, para a troca não mexer na página (TEL-16) */
.cm-convite { min-height: 182px; margin: 0 0 8px; padding: 14px 16px; border: 1px dashed rgba(226,185,111,0.35); border-radius: 10px;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 10px; }
.cm-convite p { margin: 0; }
.cm-convite .cta-btn { margin: 0; }
.cm-caixa { display: grid; gap: 8px; margin-bottom: 8px; }
.cm-caixa textarea, .cm-caixa input {
  width: 100%; font: inherit; font-size: 16px; color: var(--text-light); background: var(--bg-card); border: 1px solid rgba(226,185,111,0.35);
  border-radius: 10px; padding: 10px 12px; resize: vertical; min-height: 44px;
}
.cm-caixa textarea:focus, .cm-caixa input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.cm-caixa-pe { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.cm-caixa-pe .cta-btn { margin: 0; }
.cm-contador { margin-right: auto; font-size: 13px; color: var(--text-muted); }
.cm-msg { font-size: 14px; margin: 4px 0 0; }
.cm-msg:empty { display: none; }
.cm-msg.ok { color: var(--ok); }
.cm-msg.erro { color: var(--erro); }
.cm-total { font-size: 14px; color: var(--text-muted); margin: 14px 0 8px; }
.cm-vazio { color: var(--text-muted); font-size: 15px; }
.cm-lista, .cm-respostas { list-style: none; padding: 0; margin: 0; }
.cm { margin: 0; }
.cm-lista > .cm { border-top: 1px solid var(--linha); padding: 12px 0; }
.cm-respostas { margin: 6px 0 0 18px; padding-left: 12px; border-left: 2px solid var(--linha); }
.cm-respostas > .cm { padding: 8px 0 2px; }
.cm-corpo { min-width: 0; }
.cm-destaque { background: rgba(226,185,111,0.07); border-radius: 10px; padding: 8px 10px; }
/* comentário do link (#c-<id>): :target na lista do HTML, cm-alvo na trocada pelo JS; outline não mexe no layout */
.cm:target > .cm-corpo, .cm-alvo > .cm-corpo { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 8px; }
.cm { scroll-margin-top: 16px; }
.cm:focus { outline: none; }
.cm:focus-visible > .cm-corpo { outline: 3px solid var(--accent); outline-offset: 6px; border-radius: 8px; }
.cm-cab { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; line-height: 1.5; }
.cm-autor { display: inline-flex; align-items: center; gap: 8px; color: var(--text-light); font-weight: 600; font-size: 14px; text-decoration: none; min-height: 44px; }
.cm-autor:hover .cm-nome { text-decoration: underline; }
.cm-foto { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--bg-soft); }
.cm-letra { display: inline-flex; align-items: center; justify-content: center; color: var(--accent); font-weight: 700; border: 1px solid rgba(226,185,111,0.4); }
.cm-fixado { color: var(--accent); font-weight: 600; }
.cm-texto { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; overflow: hidden; overflow: clip; overflow-clip-margin: 4px; }   /* SEG-05: "zalgo" não invade o vizinho */
.cm-removido { font-size: 14px; color: var(--text-muted); font-style: italic; margin: 0; }
.cm-acoes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cm-acao { font: inherit; font-size: 13px; font-weight: 600; color: var(--text-muted); background: none; border: 0; border-radius: 6px; padding: 0 10px; min-height: 44px; min-width: 44px; cursor: pointer; }
.cm-acao:hover { color: var(--accent); background: rgba(255,255,255,0.04); }
.cm-acao:focus-visible { outline: 2px solid var(--accent); }
.cm-inline { margin-top: 8px; }
.cm-corpo > .cm-msg { margin-top: 6px; }
/* DES-06: no HTML do servidor não há botões; com JS, reserva a altura da linha que o navegador desenha (4 + 44 px) */
.js .cm-estatico .cm-com-acoes::after { content: ''; display: block; height: 48px; }
.cm-caixa [aria-disabled="true"], .cm-acao-mais[aria-disabled="true"] { opacity: 0.7; cursor: progress; }
/* DES-06 (D-EST-77): a linha de paginação tem 44 px nos dois desenhos — texto no HTML do servidor ("Aqui estão as 50
   conversas mais recentes.") e o botão "Ver comentários mais antigos" do navegador —, então a troca não empurra nada */
.cm-mais { margin: 4px 0 10px; min-height: 44px; display: flex; align-items: center; font-size: 14px; color: var(--text-muted); }
.cm-acao-mais { min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; margin: 0; }
.cm-mais-resp { margin: 4px 0 0 30px; min-height: 44px; display: flex; align-items: center; font-size: 13px; color: var(--text-muted); }
.cm-acao-mais-resp { min-height: 44px; display: inline-flex; align-items: center; font-size: 13px; margin: 0; }
.cm-acao-mais-resp[aria-disabled="true"] { opacity: 0.7; cursor: progress; }
.cm-aviso-destaque { color: var(--accent); margin: 0 0 6px; }
.cm-privado { cursor: default; }

/* aviso de medalha */
.est-toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50; display: flex; gap: 10px; align-items: center;
  background: var(--bg-card); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 10px 8px 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  max-width: calc(100vw - 32px); font-size: 14px;
}
.est-toast a { color: var(--accent); font-weight: 600; }

/* índice /estudos */
.ei-filtros { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0 auto 10px; max-width: 760px; }
.ei-campo { display: grid; gap: 4px; }
.ei-campo label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.ei-campo select {
  width: 100%; min-height: 44px; font: inherit; font-size: 15px; color: var(--text-light); background: var(--bg-card);
  border: 1px solid rgba(226,185,111,0.35); border-radius: 10px; padding: 0 10px;
}
.ei-filtros .btn { align-self: end; }
@media (min-width: 700px) { .ei-filtros { grid-template-columns: 1fr 1fr 1fr auto; align-items: end; } }
.ei-status { text-align: center; color: var(--text-muted); font-size: 14px; min-height: 22px; margin-bottom: 10px; }
.ei-lista { max-width: 760px; margin: 0 auto; }
.ei-item[hidden] { display: none; }
.ei-card { display: block; }
.ei-vazio { text-align: center; color: var(--text-muted); }
