/* Muro de Xisto IA — aspeto inspirado no xisto do Douro e no guia ADVID (papel, ardósia, terra).
   As cores vêm do tema (variáveis definidas em temas.ts, com contraste testado). */
:root {
  --fundo: #F3F0E8; --superficie: #FFFFFF; --texto: #23272A; --texto2: #4D5357; --borda: #7C8286;
  --acao: #1C5385; --textoAcao: #FFFFFF; --perigo: #9A3D06; --atencao: #7A5200; --nota: #2F5568;
  --pedra: #8C8A82; --pedraEscura: #4E4C47; --terra: #B79C78; --cascalho: #D3CBBE;
  --raio: 10px;
  --letra: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --letra-titulo: "Georgia", "Iowan Old Style", "Times New Roman", serif;
  color-scheme: light dark;
}
:root[data-letra="dislexia"] {
  --letra: "OpenDyslexic", "Lexend", Verdana, Tahoma, sans-serif;
  --letra-titulo: var(--letra);
  letter-spacing: 0.04em;
  word-spacing: 0.12em;
}
@font-face { font-family: "OpenDyslexic"; src: url("fontes/OpenDyslexic-Regular.woff2") format("woff2"); font-display: swap; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto);
  font: 1rem/1.55 var(--letra);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
:root[data-letra="dislexia"] body { line-height: 1.75; }
h1, h2, h3 { font-family: var(--letra-titulo); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.3rem; font-weight: 700; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
h2 small, h3 small { font: 400 .8rem var(--letra); color: var(--texto2); }
a { color: var(--acao); }
:focus-visible { outline: 3px solid var(--acao); outline-offset: 2px; }
.saltar { position: absolute; left: -999px; }
.saltar:focus { left: 8px; top: 8px; z-index: 9; background: var(--superficie); padding: .5rem; }

/* topo com as "fiadas" de xisto */
.topo {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .75rem;
  padding: calc(.6rem + env(safe-area-inset-top)) 16px .6rem;
  background: var(--fundo);
  border-bottom: 1px solid var(--borda);
}
.topo::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 6px;
  background:
    linear-gradient(90deg, var(--pedra) 0 18%, transparent 18% 19%, var(--pedraEscura) 19% 41%, transparent 41% 42%,
      var(--pedra) 42% 63%, transparent 63% 64%, var(--pedraEscura) 64% 88%, transparent 88% 89%, var(--pedra) 89%);
  opacity: .55;
}
.topo h1 { flex: 1; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marca { width: 28px; height: 28px; border-radius: 6px; background: url("icones/icone.svg") center/cover; }

main { max-width: 680px; margin: 0 auto; padding: 20px 16px 24px; display: grid; gap: 16px; }
main:focus { outline: none; }

/* barra inferior */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--superficie); border-top: 1px solid var(--borda);
  padding-bottom: env(safe-area-inset-bottom);
}
.barra a {
  min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--texto2); text-decoration: none; font-size: .85rem; gap: 2px;
}
.barra a span { font-size: 1.2rem; line-height: 1; }
.barra a[aria-current="page"] { color: var(--acao); font-weight: 700; box-shadow: inset 0 3px 0 var(--acao); }

/* cartões */
.cartao {
  background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 16px; display: block;
}
.cartao > :last-child { margin-bottom: 0; }
.cartao-link { text-decoration: none; color: var(--texto); display: grid; gap: 2px; min-height: 64px; }
.cartao-link strong { font-family: var(--letra-titulo); font-size: 1.1rem; }
.cartao-link span { color: var(--texto); }
.cartao-link small { color: var(--texto2); }
details.cartao summary { cursor: pointer; list-style: none; display: flex; align-items: center; min-height: 32px; }
details.cartao summary::after { content: "＋"; margin-left: auto; color: var(--texto2); }
details.cartao[open] summary::after { content: "－"; }
details.cartao summary h2 { margin: 0; }
details.cartao[open] summary { margin-bottom: .75rem; }

.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.vazio { color: var(--texto2); text-align: center; padding: 24px 8px; }

/* botões (≥ 48 px) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: .6rem 1.1rem; border-radius: var(--raio);
  border: 2px solid var(--acao); background: var(--acao); color: var(--textoAcao);
  font: 600 1rem var(--letra); text-decoration: none; cursor: pointer; text-align: center;
}
.btn:disabled, .btn.desativado { opacity: .45; pointer-events: none; }
.btn-sec { background: transparent; color: var(--acao); }
.btn-grande { width: 100%; min-height: 56px; font-size: 1.05rem; }
.btn-perigo-sec { background: transparent; color: var(--perigo); border-color: var(--perigo); }
.btn-icone {
  min-width: 48px; min-height: 48px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--texto); font-size: 1.4rem; text-decoration: none; cursor: pointer;
}
.linha-botoes { display: flex; gap: 10px; flex-wrap: wrap; }
.linha-botoes > * { flex: 1 1 140px; }

/* formulários */
.formulario { display: grid; gap: 14px; }
.campo { display: grid; gap: 4px; }
.campo > span { font-weight: 600; }
.campo small { color: var(--texto2); }
input, textarea {
  font: inherit; color: var(--texto); background: var(--superficie);
  border: 2px solid var(--borda); border-radius: 8px; padding: .65rem .75rem; min-height: 48px; width: 100%;
}
input:focus, textarea:focus { border-color: var(--acao); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--acao) 30%, transparent); }
input[type="range"] { padding: 0; border: 0; accent-color: var(--acao); }
.medidas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.medidas input { font-size: 1.25rem; font-variant-numeric: tabular-nums; text-align: center; }
@media (max-width: 420px) { .medidas { grid-template-columns: 1fr; } }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.segmentos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.segmentos.tres { grid-template-columns: repeat(3, 1fr); }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; min-height: 0; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 52px; padding: .4rem; border: 2px solid var(--borda); border-radius: 8px; background: var(--superficie);
}
.seg input:checked + span { border-color: var(--acao); color: var(--acao); font-weight: 700; box-shadow: inset 0 0 0 1px var(--acao); }
.seg input:checked + span::before { content: "✓ "; white-space: pre; }
.seg input:focus-visible + span { outline: 3px solid var(--acao); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: .6rem; min-height: 48px; }
.check input { width: 24px; height: 24px; min-height: 0; accent-color: var(--acao); }
details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.com-botao { display: flex; gap: 6px; }
.amostra-dislexia { font-family: "OpenDyslexic", "Lexend", Verdana, sans-serif; letter-spacing: .04em; }

/* alertas: cor + ícone + palavra */
.alertas { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alerta {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--raio); background: var(--superficie);
  border: 1px solid var(--borda); border-left-width: 6px; margin: 0;
}
.alerta-icone { font-size: 1.2rem; line-height: 1.4; }
.alerta-perigo { border-left-color: var(--perigo); }
.alerta-perigo strong { color: var(--perigo); }
.alerta-atencao { border-left-color: var(--atencao); }
.alerta-atencao strong { color: var(--atencao); }
.alerta-nota { border-left-color: var(--nota); }
.alerta-nota strong { color: var(--nota); }
.fonte { display: block; color: var(--texto2); font-size: .82rem; margin-top: 2px; }
.fonte a { color: var(--texto2); }

/* resultado */
.resumo-medidas { margin: 0; color: var(--texto2); display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; }
.ligacao { font-weight: 600; }
.resultados { margin: 0; display: grid; gap: 0; }
.resultados > div { display: grid; grid-template-columns: minmax(8rem, 38%) 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid color-mix(in srgb, var(--borda) 45%, transparent); }
.resultados > div:first-child { border-top: 0; }
.resultados dt { font-weight: 600; }
.resultados dd { margin: 0; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .resultados > div { grid-template-columns: 1fr; gap: 2px; } }
.tipos { margin: 0; padding-left: 1.1rem; display: grid; gap: 8px; }
.legenda { color: var(--texto2); font-size: .85rem; margin: .5rem 0 0; }
.aviso-legal { font-size: .88rem; color: var(--texto2); border-top: 1px solid var(--borda); padding-top: 12px; margin: 0; }
.aviso-inicial { border: 2px solid var(--atencao); }
.analise ul { padding-left: 1.1rem; }

/* perfil do muro */
.perfil { width: 100%; height: auto; display: block; font-family: var(--letra); }
.pf-solo { stroke: var(--texto2); stroke-width: 1.5; stroke-dasharray: 2 3; }
.pf-muro { fill: var(--pedra); stroke: var(--texto); stroke-width: 1.5; }
.pf-terra { fill: var(--terra); opacity: .55; }
.pf-cascalho { fill: var(--cascalho); stroke: var(--texto2); stroke-width: .75; stroke-dasharray: 1 2; }
.pf-travacao { stroke: var(--texto); stroke-width: 2; stroke-dasharray: 6 4; }
.pf-capeamento { fill: var(--pedraEscura); }
.pf-boeiro { fill: var(--superficie); stroke: var(--texto); stroke-width: 1.5; }
.pf-cota { stroke: var(--texto2); stroke-width: 1; }
.pf-rotulo { fill: var(--texto2); font-size: 11px; }
.pf-cota-txt { fill: var(--texto); font-size: 12px; font-weight: 600; }

/* passo a passo */
.progresso { margin: 0; font-weight: 600; color: var(--texto2); }
.barra-progresso { height: 8px; background: color-mix(in srgb, var(--borda) 35%, transparent); border-radius: 4px; overflow: hidden; }
.barra-progresso span { display: block; height: 100%; background: var(--acao); }
.passo h2 { font-size: 1.4rem; }
.passo-texto { font-size: 1.15rem; line-height: 1.6; }
.nav-passos { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.nav-passos .btn { padding: .5rem; white-space: nowrap; }
.nav-passos .btn { min-height: 60px; }

/* IA */
.dica { color: var(--texto2); font-size: .9rem; margin: 0; }
#previa { margin: 8px 0 0; }
#previa img { width: 100%; border-radius: var(--raio); border: 1px solid var(--borda); }
#previa figcaption { color: var(--texto2); font-size: .85rem; }
.estado { margin: 0; min-height: 1.5em; }
.nota-privacidade { color: var(--texto2); font-size: .85rem; margin: 0; }
.resultado-teste { margin: 0; min-height: 1.5em; }
.resultado-teste.ok strong { color: var(--nota); }
.resultado-teste.falha strong { color: var(--perigo); }
.chave { display: grid; gap: 8px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid color-mix(in srgb, var(--borda) 45%, transparent); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 9;
  max-width: 560px; margin: 0 auto; padding: 12px 16px; border-radius: var(--raio);
  background: var(--texto); color: var(--fundo); font-weight: 600;
}
.a-carregar { text-align: center; padding: 40vh 0; color: var(--texto2); }

@media (prefers-reduced-motion: no-preference) {
  .btn, .seg span { transition: background-color .15s, border-color .15s; }
}
