/* ===== Tutorial (issue #68) =======================================
   Folha propria da tela /tutorial. Carregada DEPOIS de main.css e
   escopada por .tut-page, entao vence as regras .tut-* antigas sem
   precisar de !important e sem tocar em main.css.

   Cor, raio, sombra e espaco saem dos tokens do DESIGN.md ja expostos
   como custom properties em main.css (--primary, --surface, --border,
   --muted, --radius, --shadow, --gutter). Nada de hex improvisado:
   os poucos valores derivados usam color-mix sobre esses tokens, o que
   mantem o par de contraste correto tambem no tema escuro.
   Sem emoji: os icones sao SVG inline no EJS. Sem JS: o menu do celular
   e um checkbox (CSP nao permite script inline). */

.tut-page {
  --tut-side-w: 260px;
  --tut-gap: clamp(1.25rem, 2.5vw, 2.25rem);
  --tut-pad: clamp(1.25rem, 2.2vw, 2rem);
  --tut-top: calc(56px + 1.5rem);
}

/* ---- Cabecalho da pagina --------------------------------------- */
.tut-page .tut-head {
  margin: 0 0 var(--tut-gap);
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}
.tut-page .tut-head h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.tut-page .tut-head p {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
  font-size: 0.975rem;
  line-height: 1.6;
}

/* ---- Grade geral ------------------------------------------------ */
.tut-page .tut-layout {
  display: grid;
  grid-template-columns: minmax(220px, var(--tut-side-w)) minmax(0, 1fr);
  gap: var(--tut-gap);
  align-items: start;
}

/* ---- Indice lateral --------------------------------------------- */
.tut-page .tut-side {
  position: sticky;
  top: var(--tut-top);
  align-self: start;
  padding: 1.1rem 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: calc(100vh - var(--tut-top) - 1.5rem);
  overflow-y: auto;
}
.tut-page .tut-side-title {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 0 0 0.3rem;
  font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.tut-page .tut-side-title svg { flex: 0 0 auto; color: var(--primary); }
.tut-page .tut-side-sub {
  margin: 0 0 1rem;
  font-size: 0.85rem; line-height: 1.5; color: var(--muted);
}

.tut-page .tut-toc { display: flex; flex-direction: column; gap: 0.15rem; }
.tut-page .tut-toc a {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border-left: 2px solid transparent;
  font-size: 0.9rem; line-height: 1.3;
  text-decoration: none; white-space: normal;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tut-page .tut-toc a .tut-toc-n {
  flex: 0 0 1.35rem; height: 1.35rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text);
}
.tut-page .tut-toc a:hover { color: var(--text); background: var(--hover); }
.tut-page .tut-toc a:focus-visible { outline: var(--focus-outline); outline-offset: 2px; }
.tut-page .tut-toc a.is-active {
  color: var(--primary); background: var(--active);
  font-weight: 650; border-left-color: var(--primary);
}
.tut-page .tut-toc a.is-active .tut-toc-n {
  background: var(--primary); color: #fff;
}

/* Botao do indice: so aparece na faixa estreita. */
.tut-page .tut-nav-burger { display: none; }

/* ---- Corpo ------------------------------------------------------ */
.tut-page .tut-content { min-width: 0; display: grid; gap: var(--tut-gap); }

.tut-page .tut {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--tut-pad);
  margin-bottom: 0;
  scroll-margin-top: 96px;
}
.tut-page .tut:target { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.tut-page .tut h2 {
  display: flex; align-items: center; gap: 0.7rem;
  margin: 0 0 1.15rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: clamp(1.15rem, 1.8vw, 1.4rem);
  line-height: 1.25; letter-spacing: -0.015em;
}
.tut-page .tut h2 .tut-n {
  flex: 0 0 auto;
  min-width: 1.85rem; height: 1.85rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--active);
  color: var(--primary);
  font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.tut-page .tut h3 { margin: 0 0 0.4rem; font-size: 1rem; letter-spacing: -0.01em; }
.tut-page .tut p { margin: 0 0 0.95rem; line-height: 1.68; max-width: 74ch; }
.tut-page .tut > p:last-child { margin-bottom: 0; }
.tut-page .tut a { color: var(--primary); text-underline-offset: 2px; }

/* ---- Passos ----------------------------------------------------- */
.tut-page .tut-steps {
  margin: 0; padding: 0;
  list-style: none;
  counter-reset: tutstep;
  display: grid; gap: 1.05rem;
}
.tut-page .tut-steps li {
  counter-increment: tutstep;
  position: relative;
  padding: 0.15rem 0 0 2.9rem;
}
.tut-page .tut-steps li::before {
  content: counter(tutstep);
  position: absolute; left: 0; top: 0;
  width: 2rem; height: 2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  background: var(--active);
  color: var(--primary);
  font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.tut-page .tut-steps li strong { display: block; margin-bottom: 0.15rem; font-weight: 650; }
.tut-page .tut-steps p { margin: 0.2rem 0 0; color: var(--muted); line-height: 1.6; }

/* ---- Cards ------------------------------------------------------ */
.tut-page .tut-grid {
  display: grid; gap: 0.9rem; margin: 0 0 1.15rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.tut-page .tut-card {
  padding: 1.05rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--text) 3%, var(--surface));
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.tut-page .tut-card:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.tut-page .tut-card h3 { color: var(--text); }
/* Texto de apoio no card: --muted (#475569) sobre superficie clara da 7:1,
   bem acima do minimo AA; nao usar cinza mais claro que este. */
.tut-page .tut-card p { margin: 0; font-size: 0.9rem; line-height: 1.6; color: var(--muted); }

/* ---- Dica ------------------------------------------------------- */
.tut-page .tut-tip {
  display: block;
  margin: 0 0 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-left: 4px solid var(--primary);
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
  color: var(--text);
  font-size: 0.925rem; line-height: 1.65;
  max-width: 78ch;
}
.tut-page .tut-tip:last-child { margin-bottom: 0; }
.tut-page .tut-tip strong { color: var(--text); }

/* ---- Glossario -------------------------------------------------- */
.tut-page .tut-dl {
  margin: 0;
  display: grid; gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.tut-page .tut-dl dt {
  font-weight: 650;
  padding-bottom: 0.15rem;
}
.tut-page .tut-dl dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem; line-height: 1.6;
}
.tut-page .tut-dl > div {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--text) 3%, var(--surface));
}

.tut-page .tut-end {
  margin: 0;
  padding: 1rem 1.15rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem; font-style: italic; line-height: 1.6;
  color: var(--muted);
}

/* ---- Responsivo ------------------------------------------------- */
@media (max-width: 960px) {
  .tut-page .tut-layout { grid-template-columns: 1fr; gap: 1rem; }

  .tut-page .tut-side {
    position: static;
    max-height: none;
    padding: 0.9rem 1rem;
  }
  .tut-page .tut-side-sub { margin-bottom: 0; }

  /* Menu colapsavel sem JS: o checkbox escondido comanda o indice. */
  .tut-page .tut-nav-burger {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.6rem;
    width: 100%;
    margin-top: 0.85rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--hover);
    font-size: 0.9rem; font-weight: 600;
    color: var(--text);
    cursor: pointer;
  }
  .tut-page .tut-nav-burger:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
  .tut-page .tut-nav-toggle:focus-visible + .tut-nav-burger { outline: var(--focus-outline); outline-offset: 2px; }
  .tut-page .tut-nav-burger .tut-chevron { transition: transform 0.2s; color: var(--muted); }

  .tut-page .tut-toc { display: none; margin-top: 0.6rem; }
  .tut-page .tut-nav-toggle:checked ~ .tut-toc { display: flex; }
  .tut-page .tut-nav-toggle:checked ~ .tut-nav-burger .tut-chevron { transform: rotate(180deg); }
}

@media (max-width: 560px) {
  .tut-page .tut { padding: 1.1rem; }
  .tut-page .tut-steps li { padding-left: 2.6rem; }
  .tut-page .tut-dl { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .tut-page .tut-card,
  .tut-page .tut-nav-burger .tut-chevron { transition: none; }
  .tut-page .tut-card:hover { transform: none; }
}
