/* ============================================================
   Apostila Seletiva 26 — folha de estilo (tela + impressão/PDF)
   Marca: Competições Senac RS. Fontes Anton + Fredoka (fonts.css).
   Impressão paginada via paged.js (numeração + cabeçalho corrido).
   ============================================================ */

:root {
  --azul:        #1331a1;
  --azul-fundo:  #0d2280;
  --azul-tinta:  #14224f;   /* corpo de texto: bem escuro, alto contraste */
  --rosa:        #f31366;
  --laranja:     #f44528;
  --amarelo:     #f8b62f;
  --verde:       #6f9a00;   /* verde da marca puxado pro escuro, pra contraste */
  --verde-vivo:  #a2ca02;

  --papel:       #ffffff;
  --fundo:       #eef1f8;
  --linha:       #dfe3f0;
  --muted:       #5a6488;

  --display: "Anton", sans-serif;
  --font: "Fredoka", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;

  --sheet-w: 860px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.62;
  color: var(--azul-tinta);
  background: var(--fundo);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- folha (a "página" branca centralizada na tela) ------------------ */
.sheet {
  max-width: var(--sheet-w);
  margin: 32px auto 96px;
  background: var(--papel);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(19, 34, 80, .10), 0 2px 8px rgba(19, 34, 80, .06);
  overflow: hidden;
}
.sheet__body {
  padding: 0 clamp(24px, 6vw, 68px) 72px;
}

/* ---- capa ------------------------------------------------------------ */
.cover {
  position: relative;
  color: #fff;
  background:
    radial-gradient(1100px 520px at 88% -10%, rgba(243, 19, 102, .55), transparent 60%),
    radial-gradient(900px 460px at -8% 108%, rgba(162, 202, 2, .40), transparent 60%),
    linear-gradient(158deg, var(--azul) 0%, var(--azul-fundo) 100%);
  padding: clamp(40px, 7vw, 76px) clamp(24px, 6vw, 68px) clamp(36px, 5vw, 56px);
  overflow: hidden;
}
.cover__top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: clamp(28px, 6vw, 54px);
}
.cover__logo {
  height: 42px;
  width: auto;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
}
.cover__brand {
  font-family: var(--font);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .9;
}
.cover__kicker {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: .04em;
  color: var(--amarelo);
  margin: 0 0 10px;
}
.cover__title {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: .96;
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  margin: 0;
  text-wrap: balance;
}
.cover__emoji { font-size: .7em; margin-left: .1em; }
.cover__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: clamp(26px, 5vw, 44px);
}
.chip {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 12px;
  padding: 9px 15px;
  backdrop-filter: blur(2px);
}
.chip__k {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .82;
}
.chip__v { font-size: .95rem; font-weight: 500; }
.cover__foot {
  margin-top: clamp(30px, 6vw, 52px);
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, .22);
  font-size: .86rem;
  font-weight: 500;
  opacity: .9;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- tipografia do corpo -------------------------------------------- */
.sheet__body h2 {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.62rem;
  line-height: 1.2;
  color: var(--azul);
  margin: 2.4em 0 .7em;
  padding-bottom: .34em;
  border-bottom: 2px solid var(--linha);
  text-wrap: balance;
}
.sheet__body h2:first-child { margin-top: 1.4em; }
.sheet__body h3 {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.22rem;
  color: var(--azul-fundo);
  margin: 1.9em 0 .5em;
  text-wrap: balance;
}
.sheet__body h4 {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.03rem;
  color: var(--azul-tinta);
  margin: 1.5em 0 .4em;
}
.sheet__body p { margin: 0 0 1.05em; }
.sheet__body strong { font-weight: 600; color: #101a3a; }
.sheet__body a {
  color: var(--azul);
  text-decoration: none;
  border-bottom: 1px solid rgba(19, 49, 161, .32);
}
.sheet__body a:hover { border-bottom-color: var(--azul); }

.sheet__body ul,
.sheet__body ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.sheet__body li { margin: .3em 0; }
.sheet__body li::marker { color: var(--rosa); font-weight: 600; }
.sheet__body ol li::marker { color: var(--azul); }

.sheet__body hr {
  border: none;
  height: 1px;
  background: var(--linha);
  margin: 2.4em 0;
}

/* ---- código --------------------------------------------------------- */
.sheet__body code {
  font-family: var(--mono);
  font-size: .86em;
  background: #eef1fb;
  color: #123;
  padding: .12em .38em;
  border-radius: 5px;
  border: 1px solid #e0e5f6;
}
.sheet__body pre {
  margin: 0 0 1.3em;
  background: #f5f7fd;
  border: 1px solid #e3e7f5;
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  line-height: 1.5;
}
.sheet__body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: .84em;
  color: #1c2540;
}

/* pygments (codehilite) — paleta clara acessível */
.codehilite .c, .codehilite .cm, .codehilite .c1, .codehilite .cs { color: #7b8399; font-style: italic; } /* comentários */
.codehilite .k, .codehilite .kd, .codehilite .kn, .codehilite .kc, .codehilite .kr { color: #1331a1; font-weight: 600; } /* keywords */
.codehilite .s, .codehilite .s1, .codehilite .s2, .codehilite .sb, .codehilite .se { color: #157a3c; } /* strings */
.codehilite .m, .codehilite .mi, .codehilite .mf, .codehilite .mh { color: #b8511a; } /* números */
.codehilite .nf, .codehilite .fm { color: #9a2bb0; } /* funções */
.codehilite .nt { color: #1331a1; font-weight: 600; } /* tags html */
.codehilite .na { color: #b8511a; } /* atributos */
.codehilite .nb, .codehilite .bp { color: #9a2bb0; } /* builtins */
.codehilite .o, .codehilite .ow { color: #b1266a; } /* operadores */
.codehilite .p { color: #4a5578; }
.codehilite .err { color: #c0392b; }

/* ---- tabelas -------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 0 1.4em; }
.sheet__body table {
  border-collapse: collapse;
  width: 100%;
  font-size: .95rem;
  border: 1px solid var(--linha);
  border-radius: 10px;
  overflow: hidden;
}
.sheet__body thead th {
  background: var(--azul);
  color: #fff;
  font-weight: 600;
  text-align: left;
  padding: 11px 14px;
  font-size: .9rem;
}
.sheet__body tbody td {
  padding: 10px 14px;
  border-top: 1px solid var(--linha);
  vertical-align: top;
}
.sheet__body tbody tr:nth-child(even) { background: #f6f8fe; }

/* ---- callouts (blockquotes com marcador) ---------------------------- */
.callout {
  position: relative;
  margin: 1.5em 0;
  padding: 15px 18px 15px 52px;
  border: 1px solid var(--c-bd, var(--linha));
  background: var(--c-bg, #f5f7fd);
  border-radius: 12px;
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout__ico {
  position: absolute;
  left: 15px;
  top: 14px;
  font-size: 1.25rem;
  line-height: 1;
}
.callout__tag {
  display: block;
  font-family: var(--font);
  font-weight: 700;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-fg, var(--azul));
  margin-bottom: .35em;
}
.callout--foco  { --c-bg: #eef2ff; --c-bd: #c7d2ff; --c-fg: #1331a1; }
.callout--gamb  { --c-bg: #f2f8e2; --c-bd: #d3e39a; --c-fg: #4c6a00; }
.callout--pega  { --c-bg: #fdeee9; --c-bd: #f6c4b2; --c-fg: #c23a1c; }
.callout--novo  { --c-bg: #fff6e3; --c-bd: #f6dca0; --c-fg: #9a6b00; }
.callout--rev   { --c-bg: #fdeaf1; --c-bd: #f6bcd2; --c-fg: #c01159; }
.callout--nota  { --c-bg: #f3f5fc; --c-bd: #d8deef; --c-fg: #2b3a70; }

/* ---- barra de ferramentas (some na impressão) ----------------------- */
.toolbar {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
  display: flex;
  gap: 8px;
}
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: .9rem;
  color: #fff;
  background: var(--azul);
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(19, 34, 80, .22);
  transition: transform .18s cubic-bezier(.2,.8,.2,1), background .18s;
}
.btn:hover { background: var(--azul-fundo); transform: translateY(-1px); }
.btn--ghost { background: #fff; color: var(--azul); box-shadow: 0 6px 18px rgba(19,34,80,.14); }
.btn--ghost:hover { background: #f0f3ff; }
.btn[disabled] { opacity: .6; cursor: default; transform: none; }

/* ---- rodapé do documento ------------------------------------------- */
.doc-foot {
  max-width: var(--sheet-w);
  margin: 0 auto 60px;
  text-align: center;
  color: var(--muted);
  font-size: .84rem;
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

/* ============================================================
   IMPRESSÃO / PDF
   ============================================================ */
@page {
  size: A4;
  margin: 16mm 14mm 16mm;
}

@media print {
  body { background: #fff; font-size: 10.8pt; line-height: 1.5; }
  .toolbar, .doc-foot { display: none !important; }
  .sheet {
    max-width: none;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }
  .sheet__body { padding: 6mm 0 0; }
  .cover {
    break-after: page;
    min-height: 252mm;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .sheet__body h2 { break-after: avoid; }
  .sheet__body h3, .sheet__body h4 { break-after: avoid; }
  .sheet__body pre,
  .callout,
  .table-wrap,
  .sheet__body table { break-inside: avoid; }
  .sheet__body tr, .sheet__body img { break-inside: avoid; }
  .sheet__body p, .sheet__body li { orphans: 3; widows: 3; }
  .sheet__body thead th,
  .cover,
  .callout,
  .sheet__body tbody tr:nth-child(even) {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  /* cada capítulo do livro começa em página nova */
  .book-chapter { break-before: page; }
  .book-chapter:first-of-type { break-before: avoid; }
}
