/* Púlpito — Poder da Fé. Tokens primeiro; nada de valor solto abaixo. */
@font-face {
  font-family: "Literata";
  src: url("fonts/literata-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  /* cor */
  --verde: #0E5C3F;
  --verde-forte: #0A4630;
  --verde-claro: #E2F0E9;
  --ouro: #F2B705;
  --ouro-fundo: #FFF4CC;
  --anil: #123A7A;
  --fundo: #F3F7F4;
  --superficie: #FFFFFF;
  --tinta: #10201A;
  --tinta-suave: #4A5D55;
  --linha: #CBD8D1;
  --perigo: #B3261E;
  --perigo-fundo: #FBE9E7;
  /* palco (modo pregação) */
  --palco: #061F17;
  --palco-superficie: #0D3225;
  --palco-tinta: #F4F8F5;
  --palco-suave: #A9C2B7;
  --tempo-ok: #3DDC97;
  --tempo-atencao: #F2B705;
  --tempo-fim: #FF7A6B;
  /* tipo */
  --serifa: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --t-1: 0.875rem;
  --t0: 1rem;
  --t1: 1.125rem;
  --t2: 1.375rem;
  --t3: 1.75rem;
  --t4: 2.25rem;
  /* espaço */
  --e1: 4px;
  --e2: 8px;
  --e3: 12px;
  --e4: 16px;
  --e5: 24px;
  --e6: 32px;
  --e7: 48px;
  /* forma */
  --raio: 10px;
  --raio-g: 16px;
  --toque: 48px;
  --sombra: 0 1px 2px rgba(16, 32, 26, 0.08), 0 6px 20px rgba(14, 92, 63, 0.08);
  --largura: 760px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--tinta);
  font-family: var(--sans);
  font-size: var(--t0);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--anil); outline-offset: 2px; border-radius: 4px; }
#app:focus { outline: none; }

.skip {
  position: absolute; left: var(--e3); top: -100px;
  background: var(--superficie); color: var(--anil); padding: var(--e3) var(--e4);
  border-radius: var(--raio); z-index: 50;
}
.skip:focus { top: var(--e3); }

/* ---------- estrutura ---------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--verde); color: #fff;
  padding: calc(var(--e2) + env(safe-area-inset-top)) var(--e4) var(--e2);
}
.bar-in {
  max-width: var(--largura); margin: 0 auto;
  display: flex; align-items: center; gap: var(--e2); min-height: var(--toque);
}
.bar-title { font-family: var(--serifa); font-weight: 600; font-size: var(--t2); line-height: 1.2; }
.bar-sub { font-size: var(--t-1); color: #D3E9DE; }
.bar-grow { flex: 1; min-width: 0; }
.bar .icon-btn { color: #fff; }
.bar .icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.bar :focus-visible { outline-color: var(--ouro); }

.page {
  max-width: var(--largura); margin: 0 auto;
  padding: var(--e5) var(--e4) calc(var(--e7) + var(--toque) + env(safe-area-inset-bottom));
}

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e2);
  min-height: var(--toque); padding: 0 var(--e5);
  border: 1.5px solid var(--linha); border-radius: var(--raio);
  background: var(--superficie); color: var(--tinta);
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--verde); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn-primary:hover { background: var(--verde-forte); border-color: var(--verde-forte); }
.btn-gold { background: var(--ouro); border-color: var(--ouro); color: var(--tinta); }
.btn-gold:hover { border-color: var(--tinta); }
.btn-danger { background: var(--perigo); border-color: var(--perigo); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--anil); padding: 0 var(--e3); }
.btn-ghost:hover { background: var(--verde-claro); border-color: transparent; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--toque); height: var(--toque); flex: none;
  border: 0; border-radius: var(--raio); background: transparent; color: var(--tinta-suave); cursor: pointer;
}
.icon-btn:hover { background: var(--verde-claro); color: var(--verde); }
.icon-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
svg.i { width: 24px; height: 24px; display: block; }

.fab {
  position: fixed; right: max(var(--e4), calc((100vw - var(--largura)) / 2 + var(--e4)));
  bottom: calc(var(--e5) + env(safe-area-inset-bottom));
  box-shadow: var(--sombra); z-index: 9;
}

/* ---------- campos ---------- */
.field { display: grid; gap: var(--e1); margin-bottom: var(--e4); }
.field label { font-size: var(--t-1); font-weight: 700; color: var(--tinta-suave); }
.field .hint { font-size: var(--t-1); color: var(--tinta-suave); }
.input, .area {
  width: 100%; min-height: var(--toque);
  padding: var(--e3) var(--e3);
  border: 1.5px solid var(--linha); border-radius: var(--raio);
  background: var(--superficie);
}
.input:focus, .area:focus { outline: 3px solid var(--anil); outline-offset: 0; border-color: var(--anil); }
.area { resize: none; overflow: hidden; line-height: 1.55; display: block; }
.input::placeholder, .area::placeholder { color: #5A6B63; }
.title-input {
  font-family: var(--serifa); font-size: var(--t3); font-weight: 600; line-height: 1.25;
  border: 0; border-bottom: 2px solid var(--linha); border-radius: 0; background: transparent; padding-left: 0; padding-right: 0;
}
.title-input:focus { outline: none; border-bottom-color: var(--verde); }
.row { display: flex; gap: var(--e3); flex-wrap: wrap; align-items: end; }
.row > .field { flex: 1 1 220px; }
.row > .field.narrow { flex: 0 0 150px; }

.search { position: relative; margin-bottom: var(--e5); }
.search svg { position: absolute; left: var(--e3); top: 12px; color: var(--tinta-suave); }
.search .input { padding-left: 44px; }

/* ---------- lista de mensagens ---------- */
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--e3); }
.card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--superficie); border: 1.5px solid var(--linha); border-radius: var(--raio-g);
  padding: var(--e4) var(--e5); text-decoration: none; color: inherit;
  border-left: 6px solid var(--verde);
}
.card:hover { border-color: var(--verde); box-shadow: var(--sombra); }
.card h3 { font-family: var(--serifa); font-size: var(--t2); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.card .ref { color: var(--anil); margin-top: var(--e1); overflow-wrap: anywhere; }
.card .meta { color: var(--tinta-suave); font-size: var(--t-1); margin-top: var(--e2); }

.empty { text-align: center; padding: var(--e7) var(--e4); }
.empty h2 { font-family: var(--serifa); font-size: var(--t3); font-weight: 600; line-height: 1.2; margin-bottom: var(--e3); }
.empty p { color: var(--tinta-suave); max-width: 44ch; margin: 0 auto var(--e5); }

/* ---------- editor ---------- */
.save-state { font-size: var(--t-1); color: #D3E9DE; white-space: nowrap; }
.section-title { font-family: var(--serifa); font-size: var(--t2); font-weight: 600; margin: var(--e6) 0 var(--e3); }
.topics { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--e3); }
.topic { background: var(--superficie); border: 1.5px solid var(--linha); border-radius: var(--raio-g); }
.topic-head { display: flex; align-items: center; gap: var(--e1); padding: var(--e2) var(--e2) var(--e2) var(--e4); }
.topic-num {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--verde-claro); color: var(--verde-forte); font-weight: 700;
}
.topic-head .input { border-color: transparent; font-weight: 700; font-size: var(--t1); min-width: 0; flex: 1; }
.topic-head .input:hover { border-color: var(--linha); }
.topic-body { padding: var(--e2) var(--e4) var(--e4); border-top: 1.5px solid var(--linha); }
.topic-body .field:last-child { margin-bottom: 0; }
.topic-tools { display: flex; justify-content: flex-end; gap: var(--e1); margin-top: var(--e3); flex-wrap: wrap; }
.add-topic { margin-top: var(--e4); border-style: dashed; }

/* ---------- ajustes / entrar ---------- */
.panel { background: var(--superficie); border: 1.5px solid var(--linha); border-radius: var(--raio-g); padding: var(--e5); margin-bottom: var(--e4); }
.panel h2 { font-family: var(--serifa); font-size: var(--t2); font-weight: 600; margin-bottom: var(--e2); }
.panel p { color: var(--tinta-suave); margin-bottom: var(--e4); max-width: 62ch; }
.panel p:last-child { margin-bottom: 0; }
.panel .actions { display: flex; gap: var(--e3); flex-wrap: wrap; }
.notice { background: var(--ouro-fundo); border-radius: var(--raio); padding: var(--e3) var(--e4); color: var(--tinta); margin-bottom: var(--e4); }
.error { background: var(--perigo-fundo); color: var(--perigo); border-radius: var(--raio); padding: var(--e3) var(--e4); margin-bottom: var(--e4); font-weight: 700; }
.auth { max-width: 420px; margin: 0 auto; padding-top: var(--e6); }
.auth h1 { font-family: var(--serifa); font-size: var(--t4); font-weight: 600; line-height: 1.15; margin-bottom: var(--e2); }
.auth .lead { color: var(--tinta-suave); margin-bottom: var(--e5); }
.auth .links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--e2); margin-top: var(--e3); }

/* ---------- diálogo e aviso ---------- */
dialog {
  border: 0; border-radius: var(--raio-g); padding: var(--e5); max-width: min(420px, calc(100vw - 32px));
  color: var(--tinta); box-shadow: var(--sombra);
}
dialog::backdrop { background: rgba(6, 31, 23, 0.6); }
dialog h2 { font-family: var(--serifa); font-size: var(--t2); font-weight: 600; margin-bottom: var(--e2); }
dialog p { color: var(--tinta-suave); margin-bottom: var(--e5); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--e3); flex-wrap: wrap; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--e6) + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--tinta); color: #fff; padding: var(--e3) var(--e5); border-radius: var(--raio);
  max-width: calc(100vw - 32px); z-index: 60; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#toast.on { opacity: 1; }

/* ---------- modo pregação (o palco) ---------- */
body.stage { background: var(--palco); color: var(--palco-tinta); }
.stage-wrap { min-height: 100dvh; display: flex; flex-direction: column; --escala: 1; }
.stage-wrap :focus-visible { outline-color: var(--ouro); }

.clock { position: sticky; top: 0; z-index: 10; background: var(--palco); padding-top: env(safe-area-inset-top); }
.clock-track { height: 12px; background: var(--palco-superficie); }
.clock-fill { height: 100%; width: 0%; background: var(--tempo-ok); transition: width 0.25s linear, background-color 0.4s; }
.clock-row .btn { padding: 0 var(--e4); }
.clock-row { display: flex; align-items: center; gap: var(--e2); padding: var(--e2) var(--e3); max-width: 1100px; margin: 0 auto; }
.clock-time { font-weight: 700; font-size: var(--t4); line-height: 1; font-variant-numeric: tabular-nums; color: var(--tempo-ok); transition: color 0.4s; }
.clock-left { color: var(--palco-suave); font-size: var(--t-1); font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock[data-fase="atencao"] .clock-fill { background: var(--tempo-atencao); }
.clock[data-fase="atencao"] .clock-time { color: var(--tempo-atencao); }
.clock[data-fase="fim"] .clock-fill { background: var(--tempo-fim); }
.clock[data-fase="fim"] .clock-time { color: var(--tempo-fim); }
.stage-wrap .icon-btn { color: var(--palco-tinta); }
.stage-wrap .icon-btn:hover { background: var(--palco-superficie); color: #fff; }
.stage-wrap .btn { background: var(--palco-superficie); border-color: var(--palco-superficie); color: var(--palco-tinta); }
.stage-wrap .btn:hover { border-color: var(--palco-suave); }
.stage-wrap .btn-gold { background: var(--ouro); border-color: var(--ouro); color: var(--tinta); }

.slide { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: var(--e5) var(--e5) var(--e6); font-size: calc(1.25rem * var(--escala)); line-height: 1.5; }
.slide .where { color: var(--palco-suave); font-size: 0.75em; margin-bottom: var(--e2); }
.slide h1 { font-family: var(--serifa); font-weight: 600; font-size: 1.9em; line-height: 1.15; margin-bottom: var(--e4); overflow-wrap: anywhere; }
.slide .key {
  font-family: var(--serifa); font-size: 1.25em; line-height: 1.35; color: var(--ouro);
  border-left: 4px solid var(--ouro); padding-left: var(--e4); margin-bottom: var(--e5);
}
.slide .block { margin-bottom: var(--e5); }
.slide .block h2 { font-size: 0.7em; font-weight: 700; color: var(--palco-suave); margin-bottom: var(--e1); }
.slide .block p { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 68ch; }
.slide .verse p { font-family: var(--serifa); color: #CFE8FF; }
.slide .blank { color: var(--palco-suave); }

.stage-nav {
  position: sticky; bottom: 0; background: var(--palco);
  padding: var(--e2) var(--e3) calc(var(--e3) + env(safe-area-inset-bottom));
  display: flex; gap: var(--e2); align-items: center; max-width: 1100px; margin: 0 auto; width: 100%;
}
.stage-nav .btn { flex: 1 1 0; min-width: 0; padding: 0 var(--e3); min-height: 60px; font-size: var(--t1); }
.stage-nav .btn[disabled] { opacity: 0.35; }

@media (min-width: 700px) {
  .page { padding-top: var(--e6); }
  .slide { font-size: calc(1.5rem * var(--escala)); padding-top: var(--e6); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
