/* tens um minutinho: uma coluna de leitura, mono em tudo, justificado, sem imagens de capa, sem JavaScript. */
:root {
  --bg: #15151b;
  --fg: #e6e4de;
  --muted: #9b9aa8;
  --rule: #2a2a35;
  --soft: #1d1d26;
  --accent: #a8aaf3;
  --accent-soft: #24244a;
  color-scheme: dark;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --measure: 42rem;
}
/* modo claro: escolhido pelo leitor no cabeçalho; o escuro é o de omissão */
:root[data-tema="claro"] {
  --bg: #fafaf7; --fg: #1d1d23; --muted: #6c6b78; --rule: #dcdce3; --soft: #f0f0f4;
  --accent: #4a4dc4; --accent-soft: #e6e6f8; color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: -0.005em;
  padding-inline: 16px;
  padding-block: 0;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 700px) { body { font-size: 17px; } }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: var(--measure); margin-inline: auto; }

/* Cabeçalho */
.top {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px;
  padding-block: 28px 14px;
  border-bottom: 1px solid var(--rule);
}
.brand { font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--fg); text-decoration: none; white-space: nowrap; }
.brand .prompt { color: var(--muted); font-weight: 400; }
.brand .cursor {
  display: inline-block; width: 0.55em; height: 1.05em; vertical-align: -0.18em; margin-left: 2px;
  background: var(--accent); animation: blink 1.1s steps(1) infinite;
}
@media (prefers-reduced-motion: reduce) { .brand .cursor { animation: none; } }
@keyframes blink { 50% { opacity: 0; } }
.nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--fg); }
.nav a[aria-current="page"] { border-bottom: 2px solid var(--accent); }

/* Vistas */
.view { padding-block: 36px 48px; }
.page-head { display: grid; gap: 10px; margin-bottom: 28px; }

h1, h2, h3 { font-weight: 600; line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.2rem); letter-spacing: -0.015em; }
h2 { font-size: 1.05rem; letter-spacing: 0.02em; }
.eyebrow { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.02em; margin: 0; }
.eyebrow b { color: var(--accent); font-weight: 600; }
.lede { font-size: 1.05em; color: var(--muted); margin: 0; max-width: 34em; }
.lede i { color: var(--fg); }
.lede p { margin: 0 0 0.8em; }
.lede p:last-child { margin: 0; }

/* Texto corrido justificado em todo o site */
.rant .body, .lede, .list .first, .chars dd, .prose p, .fig figcaption {
  text-align: justify; text-justify: inter-word; hyphens: auto; -webkit-hyphens: auto; hyphenate-limit-chars: 8 4 4;
}

/* Lista de rants */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.list li { border-bottom: 1px solid var(--rule); }
.list a {
  display: grid; grid-template-columns: 4.2rem 1fr; gap: 4px 12px; align-items: baseline;
  padding-block: 16px; color: inherit; text-decoration: none;
}
.list .num { font-size: 0.85rem; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.list .num.av { color: var(--muted); font-weight: 400; font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; }
.list .ttl { font-weight: 500; font-size: 1rem; }
.list a:hover .ttl { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }
.list .first {
  grid-column: 2; color: var(--muted); font-size: 0.95em; line-height: 1.5; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.list .when { grid-column: 2; font-size: 0.72rem; color: var(--muted); }
@media (max-width: 480px) {
  .list a { grid-template-columns: 1fr; }
  .list .num { font-size: 0.75rem; }
  .list .first, .list .when { grid-column: 1; }
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-block: 36px 12px; }
.section-head a { font-size: 0.78rem; text-decoration: none; }

/* Página de rant */
.rant header { display: grid; gap: 10px; margin-bottom: 28px; }
.rant .body p { margin: 0 0 1.25em; }
.rant .body p:last-child { margin-bottom: 0; }
.after {
  margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--rule);
  display: grid; gap: 14px; font-size: 0.8rem; color: var(--muted);
}
.after .pn { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.after .pn a { text-decoration: none; }
.after .pn a.right { text-align: right; margin-left: auto; }
.after .pn a:hover { text-decoration: underline; }
.after .pn span { display: block; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 2px; }
.note {
  font-size: 0.8rem; color: var(--muted); margin: 0;
  background: var(--soft); padding: 10px 14px; border-left: 3px solid var(--accent);
}

/* Personagens */
.chars { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--rule); }
.chars div { display: grid; grid-template-columns: 11rem 1fr; gap: 6px 18px; padding-block: 14px; border-bottom: 1px solid var(--rule); }
@media (max-width: 560px) { .chars div { grid-template-columns: 1fr; } }
.chars dt { font-weight: 600; font-size: 0.9rem; }
.chars dt small { display: block; font-weight: 400; color: var(--muted); font-size: 0.72rem; margin-top: 2px; }
.chars dd { margin: 0; font-size: 0.95em; line-height: 1.5; }

/* Prosa (sobre) */
.prose p { margin: 0 0 1.2em; }
.prose p:last-child { margin: 0; }
.prose h2 { margin-block: 1.6em 0.6em; }

/* Ilustrações: linha e cor sobre fundo transparente, servem nos dois temas */
.hero { display: grid; grid-template-columns: 1fr; gap: 20px 32px; align-items: end; }
@media (min-width: 640px) { .hero { grid-template-columns: 1.1fr 1fr; } }
.hero img { width: 100%; height: auto; max-width: 440px; justify-self: end; display: block; }
.hero .lede { align-self: center; }
.fig { margin: 0 0 28px; display: grid; gap: 8px; }
.fig img { max-width: 100%; height: auto; display: block; }
.fig figcaption { font-size: 0.72rem; color: var(--muted); }
.fim { margin-top: 40px; display: grid; justify-items: center; gap: 6px; }
.fim img { width: 150px; height: auto; display: block; }
.fim span { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.08em; }
.side { display: grid; gap: 16px 28px; align-items: center; }
@media (min-width: 640px) { .side { grid-template-columns: 1fr 200px; } }
.side img { width: 100%; max-width: 200px; height: auto; display: block; justify-self: center; }

/* Rodapé */
.foot {
  border-top: 1px solid var(--rule); padding-block: 20px 36px;
  font-size: 0.66rem; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: space-between;
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--fg); }

/* Separador de partes dentro da saga */
.rant .body .parte {
  margin: 2em 0 1em; text-align: center; font-size: 0.75rem; color: var(--muted);
  letter-spacing: 0.12em; text-transform: uppercase;
}

/* Seletor de versão: com pontuação ou a original sem pontuação, só com CSS */
.sr { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.versoes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 0.74rem; }
.versoes label {
  padding: 4px 10px; border: 1px solid var(--rule); background: var(--soft); color: var(--muted);
  cursor: pointer; border-radius: 2px; user-select: none;
}
.versoes-nota { color: var(--muted); }
#v-pontos:checked ~ header label[for="v-pontos"],
#v-original:checked ~ header label[for="v-original"] {
  color: var(--fg); border-color: var(--accent); background: var(--accent-soft);
}
#v-pontos:focus-visible ~ header label[for="v-pontos"],
#v-original:focus-visible ~ header label[for="v-original"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.v-original { display: none; }
#v-original:checked ~ .body .v-pontos { display: none; }
#v-original:checked ~ .body .v-original { display: block; }
.v-pontos p, .v-original p { margin: 0 0 1.25em; }
.v-pontos p:last-child, .v-original p:last-child { margin-bottom: 0; }

/* Ilustração do post, gerada a partir de imagens/prompts.md e preparada por imagens/preparar.py */
.rant .ilustracao { display: block; width: 100%; height: auto; margin: 12px 0 4px; border-radius: 3px; }

/* Formulário de contacto: HTML puro, envia por POST e o servidor redireciona; sem JavaScript */
.form { display: grid; gap: 6px; margin: 1.6em 0; }
.form label { font-size: 0.74rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; margin-top: 10px; }
.form input, .form textarea {
  font: inherit; font-size: 0.95rem; color: var(--fg); background: var(--soft);
  border: 1px solid var(--rule); border-radius: 2px; padding: 10px 12px; width: 100%;
}
.form textarea { resize: vertical; min-height: 10rem; line-height: 1.5; }
.form input:focus-visible, .form textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form button {
  justify-self: start; margin-top: 14px; font: inherit; font-size: 0.85rem; font-weight: 600; letter-spacing: 0.04em;
  color: var(--bg); background: var(--accent); border: 0; border-radius: 2px; padding: 10px 22px; cursor: pointer;
}
.form button:hover { filter: brightness(1.1); }
.form button:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Preferências do leitor (tema e pontuação): globais, guardadas no navegador; sem JavaScript ficam escondidas */
.prefs { flex-basis: 100%; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 18px; font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }
html:not([data-js]) .prefs, html:not([data-js]) .versoes { display: none; }
.pref { display: inline-flex; align-items: center; gap: 4px; }
.pref-nome { color: var(--muted); margin-right: 4px; }
.prefs button, .versoes button {
  font: inherit; color: var(--muted); background: transparent; border: 1px solid var(--rule);
  border-radius: 2px; padding: 2px 8px; cursor: pointer; text-transform: inherit; letter-spacing: inherit;
}
.versoes button { background: var(--soft); padding: 4px 10px; text-transform: none; letter-spacing: 0; }
.prefs button[aria-pressed="true"], .versoes button[aria-pressed="true"] { color: var(--fg); border-color: var(--accent); background: var(--accent-soft); }
.prefs button:focus-visible, .versoes button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.v-original { display: none; }
:root[data-versao="original"] .v-pontos { display: none; }
:root[data-versao="original"] .v-original { display: block; }
.prose .v-pontos p, .prose .v-original p { margin: 0 0 1.2em; }
.prose .v-pontos p:last-child, .prose .v-original p:last-child { margin: 0; }

/* Subscrição por email: formulário curto no fim de cada texto, na página inicial e em /subscrever/ */
.subs { margin: 32px 0 8px; padding: 16px; background: var(--soft); border: 1px solid var(--rule); border-radius: 3px; }
.subs label { margin-top: 0; }
.subs .linha { display: flex; flex-wrap: wrap; gap: 8px; }
.subs .linha input { flex: 1 1 14rem; width: auto; }
.subs .linha button { margin-top: 0; }
.subs-nota { margin: 6px 0 0; font-size: 0.72rem; color: var(--muted); }

/* Já inscrito neste navegador: some a caixa de subscrever; em /subscrever/ aparece um aviso em vez do formulário */
:root[data-subscrito] .subs { display: none; }
.subs-ja { display: none; }
:root[data-subscrito] .subs-ja { display: block; }
