/* ————————————————————————————————————————————————————————————————
   With.Care — Ficha de Sessão (ferramenta interna do facilitador)
   Identidade visual herdada de withcare.pt: mesmas variáveis de cor,
   mesma família tipográfica, mesmos raios e estilos de botão.
   ———————————————————————————————————————————————————————————————— */

:root {
  --ink: #163c6c;
  --muted: rgba(22, 60, 108, 0.72);
  --paper: #ffffff;
  --soft: #f8f4e2;
  --line: rgba(110, 175, 213, 0.34);
  --teal: #5bc5f2;
  --teal-dark: #163c6c;
  --sage: #71add5;
  --gold: #f8ea46;
  --wash: rgba(110, 175, 213, 0.1);
  --shadow: 0 18px 50px rgba(22, 60, 108, 0.12);
  --shadow-suave: 0 10px 28px rgba(22, 60, 108, 0.06);
  --raio: 8px;
  --margem: clamp(18px, 5vw, 40px);
  --largura: 720px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

button,
input {
  font: inherit;
  color: inherit;
}

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

ul {
  padding: 0;
  list-style: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

/* ————————————————————————————— Cabeçalho ————————————————————————————— */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px var(--margem);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.brand-logo {
  display: block;
  width: clamp(124px, 34vw, 168px);
  height: auto;
}

.topbar-tag {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  text-align: right;
}

/* ————————————————————————————— Ecrãs ————————————————————————————— */

.screen {
  padding: clamp(22px, 6vw, 44px) var(--margem) 40px;
}

.screen[hidden] {
  display: none;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.9rem, 7vw, 2.6rem);
  line-height: 1.08;
}

/* ————————————————————————— Botões (iguais a withcare.pt) ————————————————————————— */

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--raio);
  cursor: pointer;
  font-weight: 800;
  text-align: center;
}

.primary-action {
  color: #ffffff;
  background: var(--teal);
}

.secondary-action {
  color: var(--teal-dark);
  background: transparent;
  border-color: var(--line);
}

.bloco {
  width: 100%;
}

@media (hover: hover) {
  .primary-action:hover {
    background: var(--teal-dark);
  }

  .secondary-action:hover {
    background: rgba(91, 197, 242, 0.12);
  }
}

.primary-action:active,
.secondary-action:active {
  transform: translateY(1px);
}

/* ————————————————————————— 1. Porta de entrada ————————————————————————— */

.gate-screen {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 210px);
  background: var(--soft);
}

.gate-card {
  width: 100%;
  max-width: 460px;
  padding: clamp(24px, 6vw, 36px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 5px solid var(--teal);
  border-radius: var(--raio);
  box-shadow: var(--shadow);
}

.gate-intro {
  margin: 12px 0 26px;
  color: var(--muted);
}

.campo-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
}

.campo-texto {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--raio);
  font-size: 1.15rem;
  font-weight: 700;
}

.campo-texto::placeholder {
  color: rgba(22, 60, 108, 0.4);
  font-weight: 400;
}

.campo-texto[aria-invalid="true"] {
  border-color: #c0392b;
}

.erro {
  margin: 12px 0 0;
  color: #c0392b;
  font-size: 0.95rem;
  font-weight: 700;
}

#formCodigo .primary-action {
  margin-top: 18px;
}

/* ————————————————————————— 2. Formulário ————————————————————————— */

.form-screen {
  background: var(--wash);
  min-height: calc(100vh - 210px);
}

.form-card {
  max-width: var(--largura);
  margin: 0 auto;
}

.progresso-barra {
  height: 5px;
  margin-bottom: clamp(22px, 5vw, 32px);
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progresso-barra span {
  display: block;
  height: 100%;
  width: 25%;
  background: var(--teal);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.pergunta {
  margin-bottom: 8px;
}

.pergunta-ajuda {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.95rem;
}

.pergunta-ajuda[hidden] {
  display: none;
}

.opcoes {
  display: grid;
  gap: 12px;
  margin-top: clamp(22px, 5vw, 30px);
}

.opcao {
  display: block;
  width: 100%;
  min-height: 72px;
  padding: 18px 20px;
  text-align: left;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: var(--raio);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: var(--shadow-suave);
}

@media (hover: hover) {
  .opcao:hover {
    border-left-color: var(--teal-dark);
    box-shadow: 0 18px 44px rgba(22, 60, 108, 0.1);
  }
}

.opcao:active {
  transform: translateY(1px);
}

.voltar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin-top: 22px;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
}

.voltar[hidden] {
  display: none;
}

/* ————————————————————————— 3. Ficha ————————————————————————— */

.ficha-screen {
  padding-bottom: 0;
}

.ficha-screen .ficha {
  margin-bottom: 6px;
}

.ficha {
  display: grid;
  gap: 18px;
  max-width: var(--largura);
  margin: 0 auto;
}

.ficha-cabecalho {
  padding-bottom: 4px;
}

.ficha-cabecalho h1 {
  margin-bottom: 8px;
}

.ficha-ref {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

/* Blocos fixos: preparação do espaço e fecho da sessão */
.bloco-fixo {
  padding: 18px 20px;
  background: var(--soft);
  border-radius: var(--raio);
}

.bloco-fixo-titulo {
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--teal-dark);
}

.bloco-fixo p {
  font-size: 1rem;
}

/* Os três momentos */
.momento {
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 5px solid var(--teal);
  border-radius: var(--raio);
  box-shadow: var(--shadow-suave);
}

.momento-etiqueta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.momento-numero {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  color: #ffffff;
  background: var(--teal);
  border-radius: var(--raio);
  font-size: 0.95rem;
}

.momento-texto {
  font-size: 1.15rem;
  line-height: 1.45;
}

.momento-reflexao {
  border-top-color: var(--sage);
}

.frase {
  padding: 4px 0 2px 18px;
  border-left: 4px solid var(--sage);
  font-size: clamp(1.3rem, 5.2vw, 1.6rem);
  font-weight: 700;
  line-height: 1.28;
}

.perguntas-rotulo {
  margin: 22px 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.perguntas {
  display: grid;
  gap: 12px;
}

.perguntas li {
  position: relative;
  padding-left: 20px;
  font-size: 1.08rem;
  line-height: 1.4;
}

.perguntas li::before {
  content: "";
  position: absolute;
  top: 0.62em;
  left: 0;
  width: 9px;
  height: 9px;
  background: var(--sage);
  border-radius: 50%;
}

/* Notas — visualmente distintas: só o facilitador as vê */
.notas {
  background: #fdfbef;
  border: 1px dashed rgba(22, 60, 108, 0.28);
  border-radius: var(--raio);
}

.notas > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 14px 20px;
  cursor: pointer;
  list-style: none;
}

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

.notas-cabecalho {
  display: grid;
  gap: 3px;
}

.notas-titulo {
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.notas-aviso {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: none;
}

.notas-seta {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-right: 2.5px solid var(--teal-dark);
  border-bottom: 2.5px solid var(--teal-dark);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.2s ease;
}

.notas[open] .notas-seta {
  transform: rotate(-135deg) translate(-2px, -2px);
}

.notas-texto {
  padding: 0 20px 20px;
  border-top: 1px solid rgba(22, 60, 108, 0.12);
  padding-top: 16px;
  margin-top: 2px;
  font-size: 1rem;
  line-height: 1.5;
}

/* Ações no fim da ficha — o facilitador percorre a ficha toda e
   encontra os botões no fim, sem nada a tapar o conteúdo. */
.barra-acoes {
  display: grid;
  gap: 10px;
  max-width: var(--largura);
  margin: 10px auto 0;
  padding-top: 22px;
  padding-bottom: max(32px, calc(env(safe-area-inset-bottom) + 24px));
  border-top: 1px solid var(--line);
}

@media (min-width: 560px) {
  .barra-acoes {
    grid-template-columns: 1fr 1fr;
  }
}

/* ————————————————————————————— Rodapé ————————————————————————————— */

.rodape {
  padding: 26px var(--margem);
  padding-bottom: max(26px, calc(env(safe-area-inset-bottom) + 26px));
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  border-top: 1px solid var(--line);
}

/* ————————————————————————————— Impressão ————————————————————————————— */

@media print {
  .topbar,
  .barra-acoes,
  .rodape {
    display: none;
  }

  .screen {
    padding: 0;
  }

  .momento,
  .notas,
  .bloco-fixo {
    box-shadow: none;
    break-inside: avoid;
  }

  .notas-texto {
    display: block;
  }
}

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