/* Manage Everything: apresentacao em formato de calendario de mesa. Mesa escura e folhas claras com as duas
   paletas do app; superficies chapadas com fio de 1px, sem sombra nem gradiente. */

@property --sombra { syntax: '<number>'; inherits: true; initial-value: 0; }

:root {
  --mesa: #0f1412;
  --mesa-2: #0b0f0d;
  --ground-2: #1f2723;
  --ground-3: #171d1a;
  --fio-escuro: #2c3631;
  --ink: #e9eeea;
  --ink-soft: #a7b3ac;

  --papel: #ffffff;
  --papel-2: #edf0eb;
  --papel-verso: #e9ede7;
  --texto: #141a17;
  --texto-suave: #48554e;
  --texto-fraco: #5f6c65;
  --linha: #d3dad2;
  --marca: #1f6a50;
  --marca-forte: #174f3c;
  --marca-2: #80591a;

  --st-p: #b03a2c;
  --st-a: #96600f;
  --st-c: #1f7a4e;
  --st-e: #2d6598;
  --st-x: #5f6c65;

  --font-display: 'Geologica', 'Golos Text', system-ui, sans-serif;
  --font-text: 'Golos Text', system-ui, 'Segoe UI', 'Noto Sans', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;

  /* tamanho do calendario: cabe na tela mantendo a proporcao 1,6 : 1 */
  --cw: min(1120px, 92vw, calc((100svh - 190px) * 1.6));
  --ch: calc(var(--cw) / 1.6);
  --passo: 26px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; overscroll-behavior: none; }
body.ap {
  margin: 0; overflow: hidden; color: var(--ink);
  font-family: var(--font-text); line-height: 1.5; -webkit-font-smoothing: antialiased;
  background: var(--mesa);
}
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--font-display); font-weight: 600; text-wrap: balance; letter-spacing: -.01em; }
p { text-wrap: pretty; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--marca-2); outline-offset: 3px; border-radius: 4px; }

/* ---------- topo ---------- */
.ap-idiomas {
  position: fixed; inset: 0 0 auto; z-index: 21; height: 32px;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding: 0 16px;
}
.ap-idiomas::-webkit-scrollbar { display: none; }
.ap-idiomas button {
  flex: 0 0 auto; font: 500 .75rem var(--font-mono); color: var(--ink-soft); opacity: .75;
  padding: 3px 7px; border-radius: 4px; white-space: nowrap;
}
.ap-idiomas button:hover { opacity: 1; }
.ap-idiomas button.ativo { color: var(--ink); opacity: 1; background: var(--ground-2); }
.ap-nav {
  position: fixed; top: 32px; left: 0; right: 0; z-index: 20; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(20px, calc((100vw - var(--cw)) / 2));
}
.ap-nav-marca { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: .95rem; letter-spacing: -.01em; }
.ap-nav-marca img { width: 32px; height: 32px; border-radius: 8px; }
.ap-nav-entrar { font-size: .8125rem; font-weight: 600; color: var(--ink); padding: 8px 12px; border: 1px solid var(--fio-escuro); border-radius: 6px; background: var(--ground-3); transition: border-color .12s; }
.ap-nav-entrar:hover { border-color: var(--ink-soft); }

/* ---------- mesa e calendário ---------- */
.mesa {
  height: 100vh; height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 96px 0 calc(16px + env(safe-area-inset-bottom));
}
.calendario { position: relative; width: var(--cw); }

/* espiral: anéis criados no JS, sempre por cima das folhas */
.cal-espiral { position: absolute; z-index: 30; left: 0; right: 0; top: -15px; height: 30px; pointer-events: none; }
.cal-espiral span {
  position: absolute; top: 3px;
  width: 8px; height: 24px; border-radius: 4px;
  border: 2px solid var(--ink-soft); background: var(--mesa);
}

.cal-folhas {
  position: relative; height: var(--ch);
  perspective: 1900px; perspective-origin: 50% -45%;
}
.cal-folhas::after { /* folhas que ainda estao por baixo */
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -7px; height: 8px; z-index: -1;
  border: 1px solid var(--fio-escuro); border-top: 0; border-radius: 0 0 6px 6px; background: var(--ground-2);
}

.folha {
  position: absolute; inset: 0; transform-origin: 50% 0; transform-style: preserve-3d;
  visibility: hidden;
}
.folha.atual, .folha.embaixo, .folha.virando { visibility: visible; }
.folha.atual { z-index: 3; }
.folha.virando { z-index: 4; }
.folha.embaixo { z-index: 2; }

.folha-frente, .folha-verso {
  position: absolute; inset: 0; border-radius: 8px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden;
}
.folha-verso { transform: rotateX(180deg); background: var(--papel-verso); }
.folha-frente {
  display: grid; grid-template-columns: 5fr 6fr; background: var(--papel); border: 1px solid var(--fio-escuro);
  container-type: inline-size;
}
/* furos da espiral */
.folha-frente::before {
  content: ''; position: absolute; top: 0; height: 22px; left: var(--furos-ini, 28px); right: var(--furos-ini, 28px); z-index: 2; pointer-events: none;
  background: radial-gradient(circle at 50% 11px, var(--mesa) 3.5px, transparent 4px) 0 0 / var(--passo) 22px repeat-x;
}
/* sombra da folha que vira, projetada na de baixo */
.folha-frente::after {
  content: ''; position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: #0f1412;
  opacity: var(--sombra, 0);
}

/* ---------- lado da "foto" ---------- */
.folha-foto { position: relative; padding: 0; min-width: 0; }
.foto-papel {
  position: relative; height: 100%; overflow: hidden;
  display: grid; place-items: center; padding: clamp(30px, 4.6cqw, 48px) clamp(14px, 2.6cqw, 32px) clamp(14px, 2.6cqw, 32px);
  background: var(--tom-1);
}

.folha-foto[data-tom="verde"] { --tom-1: #173027; }
.folha-foto[data-tom="azul"] { --tom-1: #1b2c3b; }
.folha-foto[data-tom="dourado"] { --tom-1: #33280f; }
.foto-papel > * { position: relative; }
.foto-tipo { font-family: var(--font-mono); font-weight: 600; font-size: clamp(6rem, 18cqw, 12rem); line-height: 1; letter-spacing: -.05em; color: #7cc4a4; }

/* linha picotada entre a foto e os dias */
.folha-conteudo {
  position: relative; min-width: 0; display: flex; flex-direction: column;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--linha) transparent;
  padding: clamp(30px, 4.2cqw, 48px) clamp(20px, 3.4cqw, 40px) clamp(18px, 2.6cqw, 28px);
  color: var(--texto);
  background-image: linear-gradient(var(--linha) 50%, transparent 50%);
  background-size: 1px 10px; background-repeat: repeat-y; background-position: 0 0;
}

/* ---------- cabeçalho do mês ---------- */
.folha-mes {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding-bottom: clamp(12px, 1.8cqw, 18px); border-bottom: 1px solid var(--linha);
}
.mes-nome, .folha-titulo { font-family: var(--font-display); font-weight: 600; font-size: .875rem; color: var(--texto); text-transform: capitalize; }
.folha-titulo { line-height: 1.2; }
.folha-num { font: 500 .8125rem var(--font-mono); color: var(--texto-fraco); white-space: nowrap; }

.mini-grade {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px 2px; flex-shrink: 0;
  width: clamp(130px, 17cqw, 176px); font-size: clamp(.58rem, .8cqw, .68rem); text-align: center;
  font-variant-numeric: tabular-nums; color: var(--texto-suave);
}
.mini-grade b { font-weight: 600; color: var(--texto-fraco); font-size: .9em; }
.mini-grade span { display: grid; place-items: center; aspect-ratio: 1; border-radius: 3px; font-family: var(--font-mono); }
.mini-grade span[data-st] { color: #fff; font-weight: 600; }
.mini-grade span[data-st="p"] { background: var(--st-p); }
.mini-grade span[data-st="a"] { background: var(--st-a); }
.mini-grade span[data-st="c"] { background: var(--st-c); }
.mini-grade span[data-st="e"] { background: var(--st-e); }

/* ---------- texto da folha ---------- */
.folha-texto { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: safe center; gap: clamp(10px, 1.5cqw, 16px); padding-top: clamp(14px, 2cqw, 22px); }
.folha-texto h1 { font-size: clamp(2.4rem, 7cqw, 4.6rem); line-height: .98; color: var(--texto); }
.folha-texto h2 { font-size: clamp(1.5rem, 3.6cqw, 2.4rem); line-height: 1.08; color: var(--texto); }
.folha-texto h3 { font-size: clamp(.9rem, 1.3cqw, 1rem); font-weight: 600; color: var(--texto); }
.lead { font-size: clamp(1.02rem, 1.7cqw, 1.25rem); color: var(--texto); }
.desc, .folha-texto p { font-size: clamp(.88rem, 1.3cqw, 1rem); color: var(--texto-suave); }
.kicker { font-size: .75rem; font-weight: 500; color: var(--texto-fraco); }

.bloco { display: grid; gap: 6px; }
.legenda { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.st { display: inline-flex; align-items: center; gap: 7px; padding: 3px 9px; border: 1px solid var(--linha); border-radius: 6px; background: var(--papel-2); font-size: .75rem; font-weight: 600; }
.st::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.st-p { color: var(--st-p); }
.st-a { color: var(--st-a); }
.st-c { color: var(--st-c); }
.st-e { color: var(--st-e); }
.st-x { color: var(--st-x); }

.itens { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(8px, 1.2cqw, 12px); }
.itens li { display: grid; gap: 2px; padding-top: clamp(8px, 1.2cqw, 12px); border-top: 1px solid var(--linha); }

.passos { list-style: none; margin: 0; padding: 0; display: grid; counter-reset: passo; }
.passos li {
  counter-increment: passo; display: flex; align-items: baseline; gap: 14px;
  padding: 11px 0; border-top: 1px solid var(--linha);
  font-size: clamp(.9rem, 1.3cqw, 1rem); color: var(--texto-suave); transition: color .3s;
}
.passos li::before { content: counter(passo); flex-shrink: 0; font: 600 .9375rem var(--font-mono); color: var(--texto-fraco); transition: color .3s; }
.passos li.ativo { color: var(--texto); font-weight: 600; }
.passos li.ativo::before { color: var(--marca); }

.fin-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.fin-tab { min-height: 34px; padding: 5px 11px; border: 1px solid var(--linha); border-radius: 6px; font-size: .8125rem; font-weight: 500; color: var(--texto-suave); }
.fin-tab.ativa { background: var(--papel-2); color: var(--texto); border-color: var(--texto-suave); }
.calc { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.campo { display: grid; gap: 6px; font-size: .8125rem; font-weight: 500; color: var(--texto); }
.campo input {
  width: 100%; min-width: 0; padding: 9px 12px; border-radius: 6px; border: 1px solid var(--linha);
  background: #fff; font: inherit; font-size: 1rem; font-weight: 400; color: var(--texto);
}
.campo input:focus { outline: 2px solid var(--marca); outline-offset: 1px; }

.faq { display: grid; }
.faq details { border-top: 1px solid var(--linha); }
.faq summary {
  cursor: pointer; list-style: none; padding: 11px 0; font-size: clamp(.88rem, 1.25cqw, .98rem); font-weight: 600;
  display: flex; justify-content: space-between; gap: 12px; color: var(--texto);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--marca); font-weight: 400; font-size: 1.2em; line-height: 1; transition: transform .25s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 0 12px; font-size: .875rem; }

.acoes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.btn-principal, .btn-sec {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 18px; border-radius: 6px;
  font-weight: 600; font-size: .9375rem; transition: background .12s, border-color .12s;
}
.btn-principal { background: var(--marca); color: #fff; }
.btn-principal:hover { background: var(--marca-forte); }
.btn-sec { border: 1px solid var(--linha); color: var(--texto); }
.btn-sec:hover { border-color: var(--marca); }

.entrar a { font-size: .9rem; color: var(--marca); text-decoration: underline; text-underline-offset: 3px; }
.folha-rodape { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-top: 12px; border-top: 1px solid var(--linha); font-size: .74rem; color: var(--texto-fraco); }
.folha-rodape a:hover { color: var(--texto); }

.folha-dica { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--texto-fraco); }
.folha-dica::before { content: ''; width: 14px; height: 20px; border: 1.5px solid currentColor; border-radius: 8px; background: radial-gradient(circle at 50% 30%, currentColor 1.6px, transparent 2px); }

/* ---------- recortes da interface real ---------- */
[data-ui] {
  font-family: var(--font-text); color: var(--ink); background: var(--ground-3); border: 1px solid var(--fio-escuro); border-radius: 8px;
}
.ui-card { display: block; padding: 18px 20px; width: 100%; max-width: 330px; }
.ui-card-topo { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.ui-card-topo > div:first-child { min-width: 0; }
.ui-card-nome { font-family: var(--font-display); font-weight: 600; font-size: 1.0625rem; letter-spacing: -.01em; overflow-wrap: break-word; }
.ui-card-data { font-size: .8125rem; color: var(--ink-soft); }
.ui-dia { font: 600 1.625rem/1 var(--font-mono); letter-spacing: -.03em; color: var(--ink); margin-right: 1px; }
.ui-selo { flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; padding: 3px 9px; border: 1px solid var(--fio-escuro); border-radius: 6px; background: var(--ground-2); font-size: .75rem; font-weight: 600; transition: color .3s; }
.ui-selo::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.ui-selo.pendente { color: #ee9688; }
.ui-selo.confirmado { color: #7ccb9f; }
.ui-selo.parcial { color: #e3ae66; }
.ui-selo.concluido { color: var(--ink-soft); }
.ui-linha { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: .875rem; color: var(--ink-soft); border-top: 1px solid var(--fio-escuro); }
.ui-linha b { color: var(--ink); font: 500 .875rem var(--font-mono); white-space: nowrap; }
.ui-linha b.oculto { letter-spacing: .2em; color: var(--ink-soft); }
.ui-chip { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 4px; background: var(--ground-2); font-size: .8125rem; color: var(--ink); margin-top: 10px; transition: opacity .3s; }
.ui-chip svg, .ui-olho svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }

.ui-id { font: 600 .75rem var(--font-mono); color: #7cc4a4; white-space: nowrap; }
.ui-estrelas { color: var(--ink); letter-spacing: 2px; margin: -4px 0 6px; font-size: .875rem; }
.ui-estrelas span { color: var(--fio-escuro); }
.ui-olho { color: var(--ink-soft); }
.ui-idiomas { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.ui-idiomas span { padding: 2px 6px; border-radius: 4px; background: var(--ground-2); font: 500 .75rem var(--font-mono); color: var(--ink-soft); }

.foto-pilha { display: grid; gap: 10px; width: 100%; max-width: 340px; }
.foto-pilha .ui-card { padding: 12px 14px; }

.foto-pilha .ui-card-topo { margin: 0; }

.ui-mes-topo { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: .85rem; color: var(--ink-soft); }
.ui-mes-topo .mes-nome { color: var(--ink); font-size: 1.05rem; }
.ui-mes .mini-grade.grande { width: 100%; font-size: .78rem; gap: 4px; color: var(--ink-soft); }
.ui-mes .mini-grade.grande b { color: var(--ink-soft); font-family: var(--font-text); }
.ui-mes .mini-grade.grande span { border-radius: 3px; background: var(--ground-2); }
.ui-mes .mini-grade.grande span.vazio { background: none; }
.ui-mes .mini-grade.grande span[data-st="p"] { background: #ee9688; color: #0f1412; }
.ui-mes .mini-grade.grande span[data-st="a"] { background: #e3ae66; color: #0f1412; }
.ui-mes .mini-grade.grande span[data-st="c"] { background: #7ccb9f; color: #0f1412; }
.ui-mes .mini-grade.grande span[data-st="e"] { background: #8fb8dc; color: #0f1412; }

.ui-planos { display: grid; gap: 0; }
.ui-planos:hover { border-color: var(--ink-soft); }
.ui-planos-t { font-family: var(--font-display); font-weight: 600; font-size: 1.0625rem; margin-bottom: 8px; }
.ui-plano { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--fio-escuro); }
.ui-plano b { font-weight: 600; }
.ui-plano i { font-style: normal; font-size: .8rem; color: var(--ink-soft); }

/* ---------- navegação ---------- */
.cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-seta {
  width: 36px; height: 36px; border-radius: 6px; display: grid; place-items: center; color: var(--ink-soft);
  border: 1px solid var(--fio-escuro); transition: color .12s, border-color .12s;
}
.cal-seta svg { width: 18px; height: 18px; }
.cal-seta:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-soft); }
.cal-seta:disabled { opacity: .3; cursor: default; }
.cal-pontos { display: flex; gap: 4px; }
.cal-pontos button { display: grid; place-items: center; width: 22px; height: 28px; }
.cal-pontos button::after { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--fio-escuro); transition: width .25s ease, background .2s; }
.cal-pontos button:hover::after { background: var(--ink-soft); }
.cal-pontos button[aria-current="true"] { width: 34px; }
.cal-pontos button[aria-current="true"]::after { width: 26px; background: #7cc4a4; }

/* ---------- entrada dos elementos da folha que acabou de abrir ---------- */
@media (prefers-reduced-motion: no-preference) {
  body.abrindo .folha.atual .folha-texto > * { animation: subir .6s cubic-bezier(.22,1,.36,1) both; }
  body.abrindo .folha.atual .folha-texto > *:nth-child(2) { animation-delay: .06s; }
  body.abrindo .folha.atual .folha-texto > *:nth-child(3) { animation-delay: .12s; }
  body.abrindo .folha.atual .folha-texto > *:nth-child(4) { animation-delay: .18s; }
  body.abrindo .folha.atual .folha-texto > *:nth-child(5) { animation-delay: .24s; }
  body.abrindo .folha.atual .foto-papel > * { animation: revelar .8s cubic-bezier(.22,1,.36,1) .1s both; }
  .folha-dica::before { animation: rolar 1.8s ease-in-out infinite; }
}
@keyframes subir { from { opacity: 0; transform: translateY(10px); } }
@keyframes revelar { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes rolar { 50% { background-position: 0 4px; } }

/* ---------- celular / tela em pé ---------- */
@media (max-width: 760px), (max-aspect-ratio: 4/5) {
  :root { --cw: min(560px, 94vw); --ch: calc(100svh - 184px - env(safe-area-inset-bottom)); --passo: 22px; }
  .mesa { padding-top: 90px; gap: 10px; }
  .folha-frente { grid-template-columns: 1fr; grid-template-rows: 35% 1fr; }
  .foto-papel { padding: 24px 12px 10px; }
  .foto-pilha { gap: 8px; }
  .foto-pilha .ui-card:nth-child(3) { display: none; }
  .ui-plano i { display: none; }
  .folha-foto .ui-chip:not(#fluxo-chip) { display: none; }
  .folha-foto .ui-idiomas, .folha-foto .ui-estrelas { display: none; }
  .cal-seta { display: none; }
  .ui-mes .mini-grade.grande { font-size: .62rem; gap: 2px; }
  .folha-conteudo {
    padding: 10px 16px 12px; overflow-y: auto; overscroll-behavior: contain;
    background-image: linear-gradient(90deg, var(--linha) 50%, transparent 50%);
    background-size: 10px 1px; background-repeat: repeat-x;
  }
  .folha-texto { justify-content: flex-start; gap: 8px; padding-top: 10px; }
  .folha-mes { padding-bottom: 8px; }
  .folha-texto h1 { font-size: 2.2rem; }
  .folha-texto h2 { font-size: 1.32rem; }
  .lead { font-size: .98rem; }
  .desc, .folha-texto p, .passos li, .faq summary { font-size: .84rem; }
  .itens { gap: 6px; }
  .itens li { padding-top: 6px; }
  .itens h3 { font-size: .86rem; }
  .passos li { padding: 7px 0; }
  .faq summary { padding: 9px 0; }
  .faq details p { font-size: .82rem; }
  .folha-rodape { padding-top: 8px; font-size: .68rem; }
  .calc { grid-template-columns: 1fr 1fr; gap: 8px; }
}
@media (max-height: 560px) and (min-width: 761px) {
  .folha-dica { display: none; }
}

/* ---------- folha flexível durante a virada (montada no JS) ---------- */
.curva { position: absolute; inset: 0; transform-style: preserve-3d; pointer-events: none; }
.tira { position: absolute; left: 0; right: 0; top: 100%; transform-origin: 50% 0; transform-style: preserve-3d; }
.curva > .tira { top: 0; }
.tira-frente, .tira-verso {
  position: absolute; left: 0; right: 0; top: 0; bottom: -1px; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.tira-verso { transform: rotateX(180deg); background: var(--papel-verso); }
.tira.ultima > .tira-frente, .tira.ultima > .tira-verso { bottom: 0; border-radius: 0 0 10px 10px; }
.folha-frente.tira-conteudo { inset: auto; left: 0; width: 100%; border-radius: 8px; }
.tira-luz { position: absolute; inset: 0; background: #0f1412; opacity: 0; pointer-events: none; }

/* ainda tem texto para rolar: esmaece a borda de baixo */
.folha-conteudo.tem-mais { -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(180deg, #000 calc(100% - 36px), transparent); }
