/* ==========================================================================
   Cubo Mágico — folha de estilo compartilhada
   Usada por todas as lições (./lessons/*.html) e referências (./reference/*.html).
   Objetivo: leitura confortável na tela, impressão limpa em A4.
   ========================================================================== */

:root {
  --tinta:        #1a1714;
  --tinta-suave:  #5c554d;
  --papel:        #fdfbf7;
  --papel-nota:   #f4efe6;
  --linha:        #e0d8ca;
  --destaque:     #b4461f;
  --destaque-bg:  #fdf1ec;
  --crianca:      #1f6f4a;
  --crianca-bg:   #ecf6f0;
  --adulto:       #2c4f8a;
  --adulto-bg:    #eef2f9;

  /* Cores do cubo — tons reais de adesivo, não primárias de tela */
  --c-branco:   #f7f7f5;
  --c-amarelo:  #ffd500;
  --c-vermelho: #d5312a;
  --c-laranja:  #ef7c17;
  --c-azul:     #1163b5;
  --c-verde:    #1c9c4c;
  --c-vazio:    #cfc7ba;

  --largura: 40rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tinta:       #ece5da;
    --tinta-suave: #a79d90;
    --papel:       #171512;
    --papel-nota:  #221f1a;
    --linha:       #3b352d;
    --destaque:    #ef8b62;
    --destaque-bg: #2b1d16;
    --crianca:     #6cc79a;
    --crianca-bg:  #16281f;
    --adulto:      #8fb3e8;
    --adulto-bg:   #171f2d;
    --c-vazio:     #4a443b;
  }
}
:root[data-theme="dark"] {
  --tinta:       #ece5da;
  --tinta-suave: #a79d90;
  --papel:       #171512;
  --papel-nota:  #221f1a;
  --linha:       #3b352d;
  --destaque:    #ef8b62;
  --destaque-bg: #2b1d16;
  --crianca:     #6cc79a;
  --crianca-bg:  #16281f;
  --adulto:      #8fb3e8;
  --adulto-bg:   #171f2d;
  --c-vazio:     #4a443b;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 3rem 16px 6rem;
  background: var(--papel);
  color: var(--tinta);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 19px;
  line-height: 1.62;
  -webkit-text-size-adjust: 100%;
}

main, header, footer { max-width: var(--largura); margin-inline: auto; }

/* --- Cabeçalho ----------------------------------------------------------- */
.etiqueta {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--tinta-suave);
  margin: 0 0 .5rem;
}
h1 {
  font-size: clamp(1.75rem, 6vw, 2.4rem);
  line-height: 1.15;
  font-weight: 600;
  margin: 0 0 .4rem;
  letter-spacing: -.01em;
}
.subtitulo {
  font-style: italic;
  color: var(--tinta-suave);
  margin: 0 0 2.5rem;
  font-size: 1.05rem;
}
h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 2.8rem 0 .8rem;
  padding-top: .9rem;
  border-top: 1px solid var(--linha);
}
h3 { font-size: 1.05rem; font-weight: 600; margin: 1.8rem 0 .4rem; }

p { margin: 0 0 1.1rem; }
ul, ol { margin: 0 0 1.1rem; padding-left: 1.3rem; }
li { margin-bottom: .45rem; }
strong { font-weight: 600; }

a { color: var(--destaque); text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* --- Blocos de papel ----------------------------------------------------- */
.nota {
  background: var(--papel-nota);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  margin: 1.6rem 0;
  font-size: .95rem;
}
.nota > :last-child { margin-bottom: 0; }

/* Duas vozes: o que a criança FAZ, o que o adulto FALA. */
.faz, .fala {
  border-left: 4px solid;
  border-radius: 0 6px 6px 0;
  padding: .9rem 1.1rem;
  margin: 1.2rem 0;
  font-size: .97rem;
}
.faz  { border-color: var(--crianca); background: var(--crianca-bg); }
.fala { border-color: var(--adulto);  background: var(--adulto-bg); }
.faz > :last-child, .fala > :last-child { margin-bottom: 0; }
.faz::before, .fala::before {
  display: block;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: .35rem;
  font-weight: 600;
}
.faz::before  { content: "Ela faz"; color: var(--crianca); }
.fala::before { content: "Você diz"; color: var(--adulto); }

/* Frase-regra dentro de uma .nota: a coisa que precisa ser lembrada */
.destaque-regra { font-size: 1.08rem; }

/* Linha discreta de notação WCA, dirigida ao adulto */
.linha-notacao { text-align: center; font-size: .9rem; color: var(--tinta-suave); }

.tempo {
  display: inline-block;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .72rem;
  letter-spacing: .06em;
  background: var(--destaque-bg);
  color: var(--destaque);
  border-radius: 999px;
  padding: .2rem .7rem;
  margin-bottom: 1rem;
}

/* --- Rodapé de lição ----------------------------------------------------- */
.rodape {
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--linha);
  font-size: .9rem;
  color: var(--tinta-suave);
}
.rodape h2 { border: 0; padding: 0; margin: 0 0 .5rem; font-size: 1rem; }
.fonte {
  background: var(--papel-nota);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  margin: 1.6rem 0;
  font-size: .95rem;
}
.fonte > :last-child { margin-bottom: 0; }

.links-irmaos { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; font-size: .9rem; }

/* --- Impressão ----------------------------------------------------------- */
@media print {
  :root { --papel: #fff; --tinta: #000; --papel-nota: #f2f2f2; --linha: #bbb; }
  body { font-size: 11.5pt; padding: 0; background: #fff; }
  a { color: #000; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; word-break: break-all; }
  h2, h3 { break-after: avoid; }
  .faz, .fala, .nota, .fonte, .cubo-fig, .quiz { break-inside: avoid; }
  .nao-imprime { display: none !important; }
}

/* Menu de lições (assets/menu.js) — botão fixo no canto de cima. */
.menu-licoes {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 12px;
  z-index: 50;
  font-family: system-ui, sans-serif;
  font-size: 1rem;
}
.menu-licoes summary {
  list-style: none;
  cursor: pointer;
  padding: .55rem 1rem;
  border: 1px solid var(--linha);
  border-radius: 999px;
  background: var(--papel);
  color: var(--tinta);
  font-weight: 600;
  box-shadow: 0 2px 8px rgb(0 0 0 / .12);
}
.menu-licoes summary::-webkit-details-marker { display: none; }
.menu-licoes summary::before { content: "☰ "; }
.menu-licoes[open] summary { border-color: var(--destaque); }
.menu-licoes ol {
  list-style: none;
  margin: .4rem 0 0;
  padding: .4rem;
  width: min(20rem, calc(100vw - 24px));
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  background: var(--papel);
  border: 1px solid var(--linha);
  border-radius: .7rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / .18);
}
.menu-licoes a {
  display: grid;
  grid-template-columns: 2rem 1fr;
  align-items: center;
  padding: .6rem .5rem;
  border-radius: .45rem;
  color: var(--tinta);
  text-decoration: none;
}
.menu-licoes a:hover, .menu-licoes a:focus-visible { background: var(--destaque-bg); outline: none; }
.menu-licoes a[aria-current="page"] { background: var(--crianca-bg); color: var(--crianca); font-weight: 700; }
.menu-licoes .n { color: var(--tinta-suave); font-variant-numeric: tabular-nums; font-weight: 700; }
@media print { .menu-licoes { display: none; } }
