/* ============================================================
   Tibia Global — linguagem visual do puf3 (ver ~/dev/personal/puf3/DESIGN.md).
   Claro  = paleta 2, Hokusai "The Suspension Bridge": indigo + sage/dourado.
   Escuro = paleta 1, Friedrich "Wanderer": charcoal + cinza-azulado.
   Os valores vêm de puf3/app/globals.css — não invente tons novos aqui.
   ============================================================ */

:root {
  --bg: #1e4d70;
  --bg-2: #1a4162;
  --fg: #eef2f0;
  --muted: #93aec2;
  --soft: #1a4162;
  --line: #2f5f82;
  --accent: #a5b78b;
  --accent-soft: #294a3c;
  --emphasis: #f3d58a;
  --blob-1: rgba(160, 195, 181, 0.40);
  --blob-2: rgba(165, 183, 139, 0.32);
  --blob-3: rgba(243, 213, 138, 0.30);
  --grain-opacity: 0.22;
  --ring: rgba(165, 183, 139, 0.55);
}

:root[data-theme="dark"] {
  --bg: #171815;
  --bg-2: #1f201c;
  --fg: #dcdad5;
  --muted: #8c8a84;
  --soft: #322f2a;
  --line: #43413c;
  --accent: #a0a4b8;
  --accent-soft: #34394a;
  --emphasis: #a0a4b8;
  /* Friedrich não tem atmosfera de blob — só o charcoal e o grain. */
  --blob-1: transparent;
  --blob-2: transparent;
  --blob-3: transparent;
  --grain-opacity: 0.25;
  --ring: rgba(160, 164, 184, 0.60);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.7;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Blobs desfocados que derivam devagar (só na paleta Hokusai). */
body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(38% 42% at 16% 12%, var(--blob-1), transparent 70%),
    radial-gradient(44% 48% at 86% 20%, var(--blob-2), transparent 72%),
    radial-gradient(46% 52% at 40% 96%, var(--blob-3), transparent 75%);
  filter: blur(60px) saturate(1.08);
  animation: drift 32s ease-in-out infinite;
}

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  33% { transform: translate3d(1.5%, -1%, 0) scale(1.04); }
  66% { transform: translate3d(-1.2%, 1.6%, 0) scale(1.02); }
}

/* Grain: z-index -1 pinta acima dos blobs mas abaixo de todo conteúdo em fluxo,
   então só aparece no fundo exposto — nunca borrado por cima do texto. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: hard-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch' result='n'/%3E%3CfeColorMatrix in='n' type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='1.7' intercept='-0.35'/%3E%3CfeFuncG type='linear' slope='1.7' intercept='-0.35'/%3E%3CfeFuncB type='linear' slope='1.7' intercept='-0.35'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* ---------- shell ---------- */

.wrap {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 clamp(18px, 5vw, 40px);
}

.site-head {
  border-bottom: 1px solid var(--line);
  padding: 22px 0 0;
}

.site-head .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 14px 20px;
}

.brand {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 17px;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

.brand-sub {
  flex: 1 1 14rem;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.theme-toggle:hover { color: var(--fg); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* nav */
.site-nav { margin-top: 16px; }

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 20px;
  list-style: none;
  margin: 0;
  padding: 0 0 10px;
}

.site-nav a {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 0;
  display: inline-block;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.site-nav a:hover { color: var(--fg); }
.site-nav a[aria-current="page"] { color: var(--emphasis); border-bottom-color: var(--accent); }

/* ---------- tipografia ---------- */

main { padding: 40px 0 0; }

.prose { max-width: 44rem; }

h1 {
  font-size: clamp(30px, 5vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.022em;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--fg);
}

.deck {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
  margin: 0 0 8px;
  max-width: 40rem;
}

h2 {
  font-size: 22px;
  letter-spacing: -0.012em;
  font-weight: 600;
  margin: 0 0 4px;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 26px 0 6px;
}

h4 {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 500;
  margin: 22px 0 6px;
}

p { margin: 0 0 14px; }

/* O label mono é a assinatura da casa. */
.label {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin: 0 0 10px;
}

.num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

strong, b { font-weight: 600; color: var(--emphasis); }

a { color: var(--muted); text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { color: var(--accent); }

code, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--soft);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ---------- seções em hairline ---------- */

.section {
  border-top: 1px solid var(--line);
  padding: 34px 0;
}

.section:first-of-type { border-top: none; padding-top: 8px; }

.section > .label { margin-bottom: 14px; }

/* listas com bullet mínimo */
ul.dot, ol.num-list { margin: 0 0 16px; padding: 0; list-style: none; }

ul.dot > li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 9px;
  max-width: 44rem;
}

ul.dot > li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 3px;
  height: 3px;
  background: var(--accent);
  border-radius: 50%;
}

ol.num-list { counter-reset: n; }

ol.num-list > li {
  counter-increment: n;
  position: relative;
  padding-left: 34px;
  margin-bottom: 14px;
  max-width: 44rem;
}

ol.num-list > li::before {
  content: counter(n, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.12em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--accent);
}

/* ---------- then → now: o momento de craft ---------- */

.tn { margin: 0 0 4px; }

.tn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.tn-row:last-child { border-bottom: 1px solid var(--line); }

.tn-head {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 5px;
}

.tn-then { color: var(--muted); }
.tn-now { color: var(--fg); }
.tn-now .tn-head { color: var(--accent); }

.tn-topic {
  grid-column: 1 / -1;
  font-weight: 600;
  color: var(--emphasis);
  margin-bottom: 9px;
  letter-spacing: -0.005em;
}

@media (max-width: 720px) {
  .tn-row { grid-template-columns: 1fr; gap: 14px; }
}

/* ---------- tabelas ---------- */

.table-scroll { overflow-x: auto; margin: 0 0 18px; }

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 34rem;
  font-size: 14px;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 10px 16px 10px 0;
  border-bottom: 1px solid var(--line);
}

thead th {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 500;
  border-bottom-color: var(--line);
  white-space: nowrap;
}

td.lvl {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--emphasis);
  white-space: nowrap;
}

tbody tr:hover { background: var(--soft); }

/* ---------- pequenos componentes ---------- */

.tag {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  background: var(--soft);
  border-radius: 999px;
  padding: 3px 9px;
  margin: 0 6px 6px 0;
}

.note {
  border-left: 2px solid var(--accent);
  background: var(--soft);
  padding: 12px 16px;
  margin: 0 0 18px;
  max-width: 44rem;
  font-size: 14.5px;
}

.note > :last-child { margin-bottom: 0; }

.note .label { margin-bottom: 5px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin: 0 0 20px;
}

.cards > * {
  background: var(--bg);
  padding: 18px 20px;
}

.cards h3 { margin-top: 0; }
.cards p:last-child { margin-bottom: 0; }

/* mapa do site na home */
.map { border-top: 1px solid var(--line); }

.map a {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0 14px;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.2s ease;
}

.map a:hover { background: var(--soft); }

.map .idx {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
}

.map .ttl { font-weight: 600; color: var(--emphasis); letter-spacing: -0.005em; }
.map .dsc { grid-column: 2; color: var(--muted); font-size: 14px; line-height: 1.55; }

/* ---------- rodapé ---------- */

.site-foot {
  border-top: 1px solid var(--line);
  margin-top: 48px;
  padding: 24px 0 48px;
  color: var(--muted);
  font-size: 12.5px;
}

.site-foot p { margin: 0 0 8px; max-width: 44rem; }

/* ---------- alvos obrigatórios ---------- */

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  * { transition: none !important; }
}

@media print {
  body::before, body::after { display: none !important; }
  body { background: #fff; color: #111; }
  .site-nav, .theme-toggle { display: none; }
  a { color: #111; text-decoration: none; }
  .tn-row, th, td, .section { border-color: #ccc; }
}
