/*
  MãeSegura — aplicação da gestante.

  A linguagem visual vem da capulana, o tecido que estas mulheres vestem e em
  que embrulham o recém-nascido: a faixa padronizada do topo é a «barra» do
  pano, e a paleta é a de Nampula — verde de cajueiro, âmbar de manga madura,
  terra laterítica.

  Tipografia: pilha do sistema, de propósito. Um tipo de letra externo custaria
  uma ligação e dezenas de kB a quem tem 2G, e baixo consumo de dados é um
  requisito do produto, não um detalhe. O carácter vem da escala, do peso e do
  espaçamento.

  Sem maiúsculas em rótulos: texto em caixa alta lê-se pior, e metade destas
  utilizadoras tem pouca literacia.
*/

:root {
  /* Verde de cajueiro */
  --verde: #0e4c45;
  --verde-fundo: #e4efea;
  --verde-escuro: #0a3832;

  /* Âmbar de manga madura — o acento, nunca o fundo */
  --ambar: #b87514;
  --ambar-fundo: #fbf0dc;

  /* Terra laterítica, para o perigo */
  --perigo: #9c1a20;
  --perigo-fundo: #fbe8e6;

  --tinta: #16221f;
  --tinta-suave: #5a6b66;
  --linha: #d7e2dd;
  --papel: #f3f7f4;
  --branco: #ffffff;

  --raio: 14px;
  --sombra: 0 1px 2px rgba(14, 76, 69, .05), 0 8px 24px -12px rgba(14, 76, 69, .18);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.62;
  color: var(--tinta);
  background: var(--papel);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 3px solid var(--ambar); outline-offset: 3px; border-radius: 6px; }

/* --- A barra da capulana -------------------------------------------------- */
.barra-capulana {
  height: 10px;
  flex: none;
  background-color: var(--verde-escuro);
  /* Losangos, o motivo tecido da barra de uma capulana. Desenhado aqui para
     não custar uma ligação de rede a quem tem 2G. */
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='10' viewBox='0 0 18 10'><rect width='18' height='10' fill='%230a3832'/><path d='M9 1.2 L16 5 L9 8.8 L2 5 Z' fill='%23b87514'/><path d='M0 5 L1 4.4 L1 5.6 Z' fill='%23b87514'/><path d='M18 5 L17 4.4 L17 5.6 Z' fill='%23b87514'/></svg>");
  background-repeat: repeat-x;
  background-size: 18px 10px;
}

/* --- Topo ----------------------------------------------------------------- */
.topo {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  background: var(--verde);
  color: #fff;
}
.marca { color: #fff; text-decoration: none; display: block; margin-right: 12px; min-width: 0; }
.marca-nome { display: block; font-size: 1.22rem; font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; }
.marca-lema { display: block; font-size: .78rem; opacity: .82; }
.idioma {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  flex: none;
  color: #fff;
  text-decoration: none;
  border: 1.5px solid rgba(255, 255, 255, .5);
  border-radius: 999px;
  padding: 0 16px;
  font-size: .9rem;
  font-weight: 500;
}

/* --- Folha ---------------------------------------------------------------- */
.folha {
  flex: 1 1 auto;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 26px 18px 36px;
}

h1 {
  font-size: 1.62rem;
  line-height: 1.22;
  letter-spacing: -0.025em;
  font-weight: 650;
  margin: 0 0 10px;
  max-width: 20ch;
}
h2 { font-size: 1.1rem; letter-spacing: -0.01em; margin: 32px 0 12px; }
.explicacao { color: var(--tinta-suave); margin: 0 0 26px; max-width: 46ch; }

/* --- A jornada: 40 semanas, 8 consultas ----------------------------------- */
.jornada {
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 26px 22px 22px;
  margin-bottom: 18px;
}
.jornada-semana { display: flex; align-items: baseline; margin-bottom: 4px; }
.jornada-numero {
  font-size: 3.6rem;
  font-weight: 700;
  line-height: .95;
  letter-spacing: -0.045em;
  color: var(--verde);
  font-variant-numeric: tabular-nums;
  margin-right: 12px;
}
.jornada-rotulo { font-size: 1.02rem; color: var(--tinta-suave); }
.jornada-falta { color: var(--tinta-suave); font-size: .92rem; margin: 0 0 20px; }

.trilho { height: 30px; margin-bottom: 6px; }
/* margem interior para as marcas nos extremos caberem inteiras */
.trilho-interior { position: relative; display: block; height: 100%; margin: 0 13px; }
.trilho-linha {
  position: absolute;
  left: 0; right: 0; top: 13px;
  height: 4px;
  border-radius: 999px;
  background: var(--verde-fundo);
}
.trilho-feito {
  position: absolute;
  left: 0; top: 13px;
  height: 4px;
  border-radius: 999px;
  background: var(--verde);
}
.trilho-marca {
  position: absolute;
  top: 7px;
  width: 16px; height: 16px;
  margin-left: -8px;
  border-radius: 999px;
  background: var(--branco);
  border: 3px solid var(--verde-fundo);
  box-shadow: inset 0 0 0 2px var(--branco);
}
.trilho-marca:not(.passou):not(.agora) { border-color: #b9cfc7; }
.trilho-marca.passou { background: var(--verde); border-color: var(--branco); box-shadow: none; }
.trilho-marca.agora {
  top: 3px;
  width: 24px; height: 24px;
  margin-left: -12px;
  background: var(--ambar);
  border: 4px solid var(--branco);
  box-shadow: 0 0 0 3px var(--ambar-fundo);
}
.trilho-legenda {
  margin: 0;
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--tinta-suave);
}

/* --- Cartões de informação ------------------------------------------------ */
.cartao {
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 18px 20px;
  margin-bottom: 14px;
}
.cartao-rotulo { display: block; font-size: .88rem; color: var(--tinta-suave); margin-bottom: 2px; }
.cartao-valor { display: block; font-size: 1.32rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; }
.cartao-nota { display: block; font-size: .88rem; color: var(--ambar); font-weight: 600; margin-top: 3px; }

.codigo-gestante {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: .14em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--verde);
  display: block;
  margin: 2px 0 6px;
}

/* --- Formulários ---------------------------------------------------------- */
.campo { margin-bottom: 22px; }
.campo > label { display: block; font-weight: 600; margin-bottom: 5px; }
.campo .ajuda { display: block; color: var(--tinta-suave); font-size: .9rem; margin-bottom: 9px; }

input[type="text"], input[type="tel"], input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* abaixo disto o iOS amplia a página ao tocar no campo */
  min-height: 54px;
  padding: 14px 15px;
  border: 1.5px solid var(--linha);
  border-radius: 11px;
  background: var(--branco);
  color: var(--tinta);
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--ambar);
  outline-offset: 0;
  border-color: var(--ambar);
}
textarea { min-height: 116px; resize: vertical; line-height: 1.55; }

.consentimento {
  display: flex;
  align-items: flex-start;
  background: var(--verde-fundo);
  border-radius: 11px;
  padding: 17px;
}
.consentimento input { width: 26px; height: 26px; min-height: 0; margin: 2px 13px 0 0; flex: none; accent-color: var(--verde); }
.consentimento span { font-size: .95rem; font-weight: 400; line-height: 1.55; }

.erro { color: var(--perigo); font-weight: 600; margin-top: 7px; }

.botao {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  font: inherit;
  font-weight: 650;
  font-size: 1.04rem;
  padding: 14px 18px;
  border: 2px solid transparent;
  border-radius: 11px;
  background: var(--verde);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
.botao:active { transform: translateY(1px); }
.botao-secundario { background: var(--branco); color: var(--verde); border-color: var(--verde); }
.ligacao-discreta { display: inline-block; margin-top: 20px; color: var(--verde); font-weight: 500; }

/* --- Consultas ------------------------------------------------------------ */
.consultas { list-style: none; margin: 0; padding: 0; }
.consultas li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 15px 0;
  border-bottom: 1px solid var(--linha);
}
.consultas li:last-child { border-bottom: none; }
.consultas li > span:first-child { margin-right: 12px; }
.consultas .quando { font-weight: 600; }
.consultas .semana { color: var(--tinta-suave); font-size: .88rem; }
.etiqueta { font-size: .8rem; font-weight: 600; padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.etiqueta-marcada { background: var(--verde-fundo); color: var(--verde); }
.etiqueta-realizada { background: #eef2f0; color: var(--tinta-suave); }
.etiqueta-atraso { background: var(--ambar-fundo); color: var(--ambar); }

/* --- Respostas do assistente ---------------------------------------------- */
.resposta {
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 20px;
  margin: 18px 0;
}
.resposta h3 { margin: 0 0 9px; font-size: 1.06rem; letter-spacing: -0.01em; }
.resposta p { margin: 0 0 11px; }
.resposta p:last-child { margin-bottom: 0; }
.resposta .meta { font-size: .82rem; color: var(--tinta-suave); line-height: 1.5; }
.resposta-urgente { border-left: 5px solid var(--perigo); background: var(--perigo-fundo); }
.resposta-atencao { border-left: 5px solid var(--ambar); background: var(--ambar-fundo); }

/*
  O sinal de perigo é o único sítio onde o desenho grita. Uma mulher que está a
  sangrar tem de perceber em dois segundos o que fazer, e o telefone da unidade
  tem de estar debaixo do polegar.
*/
.chamada-urgente {
  background: var(--perigo);
  color: #fff;
  border-radius: var(--raio);
  padding: 24px 22px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px -12px rgba(156, 26, 32, .6);
}
.chamada-urgente strong {
  display: block;
  font-size: 1.42rem;
  line-height: 1.22;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.chamada-urgente span { display: block; opacity: .95; }
.chamada-urgente .unidade-nome {
  margin-top: 9px;
  font-size: .88rem;
  opacity: .9;
  text-align: center;
}
.chamada-urgente .telefone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  margin-top: 18px;
  padding: 0 18px;
  background: #fff;
  color: var(--perigo);
  border-radius: 11px;
  font-weight: 700;
  font-size: 1.08rem;
  text-decoration: none;
}

.sugestoes { list-style: none; margin: 10px 0 0; padding: 0; }
.sugestoes li { border-bottom: 1px solid var(--linha); }
.sugestoes li:last-child { border-bottom: none; }
.sugestoes button {
  width: 100%;
  min-height: 54px;
  text-align: left;
  font: inherit;
  background: none;
  border: none;
  padding: 13px 0;
  color: var(--verde);
  font-weight: 500;
  cursor: pointer;
}

/* --- Painel público ------------------------------------------------------- */
.metricas { display: flex; flex-wrap: wrap; gap: 13px; }
.metrica {
  flex: 1 1 160px;
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 18px 20px;
}
.metrica .numero { display: block; font-size: 2rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.035em; color: var(--verde); font-variant-numeric: tabular-nums; }
.metrica .nome { display: block; font-size: .87rem; color: var(--tinta-suave); margin-top: 2px; }
.barra-idioma { margin: 14px 0; }
.barra-idioma .nome { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 5px; }
.barra-idioma .calha { display: block; background: var(--verde-fundo); border-radius: 999px; height: 10px; overflow: hidden; }
.barra-idioma .preenchido { display: block; background: var(--verde); height: 100%; min-width: 3px; border-radius: 999px; }

/* --- Rodapé --------------------------------------------------------------- */
.barra {
  position: sticky;
  bottom: 0;
  flex: none;
  display: flex;
  border-top: 1px solid var(--linha);
  background: var(--branco);
  padding-bottom: env(safe-area-inset-bottom);
}
.barra a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 8px;
  text-align: center;
  color: var(--verde);
  text-decoration: none;
  font-size: .93rem;
  font-weight: 600;
}
.barra a + a { border-left: 1px solid var(--linha); }
.aviso-legal {
  flex: none;
  margin: 0;
  padding: 14px 18px 20px;
  font-size: .79rem;
  line-height: 1.5;
  color: var(--tinta-suave);
  text-align: center;
  background: var(--branco);
}
.sem-rede {
  background: var(--ambar-fundo);
  color: var(--ambar);
  font-weight: 500;
  padding: 13px 18px;
  font-size: .91rem;
  text-align: center;
  border-radius: 11px;
  margin: 0 0 18px;
}
[hidden] { display: none !important; }

/* --- Ecrãs maiores -------------------------------------------------------- */
@media (min-width: 720px) {
  body { font-size: 18px; }
  .folha { padding: 36px 24px 48px; }
  h1 { font-size: 2rem; }
  .jornada { padding: 32px 28px 26px; }
  .jornada-numero { font-size: 4.4rem; }
  .botao { max-width: 440px; }
  .barra a { min-height: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --papel: #0d1614;
    --branco: #13201d;
    --tinta: #e8f0ed;
    --tinta-suave: #93a8a2;
    --linha: #26352f;
    --verde-fundo: #15322c;
    --ambar-fundo: #2e2411;
    --perigo-fundo: #33151a;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  }
  .metrica .numero, .jornada-numero, .codigo-gestante { color: #6fcbb4; }
  .botao-secundario { color: #6fcbb4; border-color: #6fcbb4; }
  .barra a, .ligacao-discreta, .sugestoes button { color: #6fcbb4; }
}
