/* Site do projeto — tokens de cor (claro/escuro) e layout. */
:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --line: #e1e0da;
  --ink: #0b0b0b;
  --ink-2: #3d3c39;
  --muted: #6b6a65;
  --accent: #0f7a63;
  --accent-ink: #ffffff;
  --accent-soft: #dff1eb;
  --warn: #b25f00;
  --warn-soft: #fbefdc;
  --bad: #c0362f;
  --bad-soft: #fbe6e3;
  --code-bg: #121615;
  --code-ink: #dfe8e4;
  --hero-1: #0b2a24;
  --hero-2: #0f4a3d;
  --hero-ink: #f2f7f5;
  --hero-muted: #a9c4bb;
  /* séries (políticas) — mesmas cores das figuras do artigo */
  --pA: #52514e; --pB: #eda100; --pBOR: #1baf7a; --pC: #2a78d6; --pD: #eb6834;
  --grid: #e4e4e0;
  --div-neg: #2a78d6; --div-mid: #f0efec; --div-pos: #e34948;
  --seq-0: #cde2fb; --seq-1: #86b6ef; --seq-2: #3987e5; --seq-3: #1c5cab; --seq-4: #0d366b;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --radius: 14px;
  --maxw: 1180px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #31312e;
    --ink: #f0efec; --ink-2: #d6d5ce; --muted: #a3a29a;
    --accent: #3cc7a2; --accent-ink: #06231b; --accent-soft: #143a31;
    --warn: #f0a542; --warn-soft: #3a2a12; --bad: #ef7a72; --bad-soft: #3d1d1a;
    --code-bg: #0c0e0d; --code-ink: #dfe8e4;
    --hero-1: #07130f; --hero-2: #0d3027;
    --pA: #7d7c77; --pB: #c98500; --pBOR: #199e70; --pC: #3987e5; --pD: #d95926;
    --grid: #2e2e2b;
    --div-neg: #3987e5; --div-mid: #383835; --div-pos: #e66767;
    --seq-0: #1c2a3d; --seq-1: #184f95; --seq-2: #2a78d6; --seq-3: #6da7ec; --seq-4: #cde2fb;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #31312e;
  --ink: #f0efec; --ink-2: #d6d5ce; --muted: #a3a29a;
  --accent: #3cc7a2; --accent-ink: #06231b; --accent-soft: #143a31;
  --warn: #f0a542; --warn-soft: #3a2a12; --bad: #ef7a72; --bad-soft: #3d1d1a;
  --code-bg: #0c0e0d; --code-ink: #dfe8e4;
  --hero-1: #07130f; --hero-2: #0d3027;
  --pA: #7d7c77; --pB: #c98500; --pBOR: #199e70; --pC: #3987e5; --pD: #d95926;
  --grid: #2e2e2b;
  --div-neg: #3987e5; --div-mid: #383835; --div-pos: #e66767;
  --seq-0: #1c2a3d; --seq-1: #184f95; --seq-2: #2a78d6; --seq-3: #6da7ec; --seq-4: #cde2fb;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img, video { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
code, pre, kbd { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
:not(pre) > code { font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.015em; }
h2 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: .6rem; }
.lead { font-size: 1.12rem; color: var(--ink-2); max-width: 760px; }

/* ---------------- navegação */
.topbar {
  position: sticky; top: 0; z-index: 50; backdrop-filter: saturate(1.4) blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent); border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand svg { flex: none; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; justify-content: flex-end; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: .86rem; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover, .nav a.on { background: var(--surface-2); color: var(--ink); }
.iconbtn { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.iconbtn:hover { border-color: var(--accent); }
@media (max-width: 1180px) { .nav { display: none; } .topbar .wrap { justify-content: space-between; } }

/* ---------------- hero */
.hero {
  position: relative; overflow: hidden; color: var(--hero-ink);
  background: radial-gradient(1200px 500px at 85% -10%, #1d7a62 0%, transparent 60%), linear-gradient(160deg, var(--hero-1), var(--hero-2));
  padding: 72px 0 64px;
}
.hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px); background-size: 22px 22px; pointer-events: none; }
.hero .wrap { position: relative; z-index: 1; display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); font-weight: 800; letter-spacing: -.03em; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, #6ff0c9, #b8f36b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--hero-muted); font-size: 1.1rem; max-width: 620px; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: #d7efe7; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); padding: 5px 12px; border-radius: 999px; margin-bottom: 18px; }
.pill b { color: #6ff0c9; }
.ctas { display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0 8px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 11px; font-weight: 600; font-size: .95rem; text-decoration: none; border: 1px solid transparent; cursor: pointer; }
.btn.primary { background: #6ff0c9; color: #04241b; }
.btn.primary:hover { background: #8ff5d6; }
.btn.ghost { border-color: rgba(255,255,255,.25); color: var(--hero-ink); background: rgba(255,255,255,.04); }
.btn.ghost:hover { background: rgba(255,255,255,.1); }
.btn.line { border-color: var(--line); color: var(--ink); background: var(--surface); }
.btn.line:hover { border-color: var(--accent); }
.hero-visual { position: relative; }
.hero-visual .frame { border-radius: 18px; overflow: hidden; border: 1px solid rgba(255,255,255,.14); box-shadow: 0 30px 60px rgba(0,0,0,.4); background: #fff; }
.hero-visual video { width: 100%; aspect-ratio: 550/770; object-fit: cover; max-height: 520px; }
.hero-visual .cap { font-size: .78rem; color: var(--hero-muted); margin-top: 10px; }
.stats { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 46px; }
.stat { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 16px 18px; }
.stat b { display: block; font-size: 1.9rem; font-weight: 800; color: #fff; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: .84rem; color: var(--hero-muted); }
@media (max-width: 900px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .hero-visual { max-width: 420px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- seções */
section.sec { padding: 84px 0; border-bottom: 1px solid var(--line); }
section.sec.alt { background: var(--surface); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } .grid4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .grid4 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
section.alt .card { background: var(--bg); }
.card h3 { margin-bottom: .4em; }
.card p:last-child { margin-bottom: 0; }
.kicker { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.callout { border-left: 4px solid var(--warn); background: var(--warn-soft); padding: 14px 18px; border-radius: 0 12px 12px 0; margin: 20px 0; color: var(--ink); }
.callout.ok { border-color: var(--accent); background: var(--accent-soft); }
.callout.bad { border-color: var(--bad); background: var(--bad-soft); }
.callout b:first-child { display: block; margin-bottom: 2px; }
ul.clean { list-style: none; padding: 0; margin: 0; }
ul.clean li { padding: 6px 0 6px 26px; position: relative; }
ul.clean li::before { content: ""; position: absolute; left: 4px; top: 15px; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }

/* linha do tempo */
.timeline { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-top: 30px; }
.timeline::before { content: ""; position: absolute; left: 0; right: 0; top: 17px; height: 2px; background: linear-gradient(90deg, var(--muted), var(--accent)); opacity: .5; }
.tl { position: relative; padding-top: 44px; }
.tl::before { content: attr(data-n); position: absolute; top: 0; left: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: var(--accent); }
.tl.old::before { border-color: var(--muted); color: var(--muted); }
.tl h4 { font-size: 1rem; margin-bottom: .3em; }
.tl p { font-size: .9rem; color: var(--ink-2); }
@media (max-width: 900px) { .timeline { grid-template-columns: 1fr; } .timeline::before { display: none; } }

/* compare antes/depois */
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.vs > div { padding: 22px; }
.vs > div:first-child { background: var(--surface-2); }
.vs > div:last-child { background: var(--surface); }
.vs h4 { margin-bottom: .8em; }
.vs li { margin-bottom: 6px; font-size: .94rem; }
@media (max-width: 760px) { .vs { grid-template-columns: 1fr; } }

/* políticas */
.pol { position: relative; padding-top: 26px; }
.pol .sw { position: absolute; top: 0; left: 22px; right: 22px; height: 4px; border-radius: 0 0 4px 4px; }
.pol .badge { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 26px; padding: 0 8px; border-radius: 7px; font-weight: 800; font-size: .85rem; color: #fff; margin-bottom: 10px; }
.pol p { font-size: .92rem; color: var(--ink-2); }

/* figuras */
figure { margin: 0; }
figure img { border-radius: 10px; background: #fff; border: 1px solid var(--line); cursor: zoom-in; }
figcaption { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 900px) { .gallery { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .gallery { grid-template-columns: 1fr; } }
.gallery img { aspect-ratio: 4/3; object-fit: contain; width: 100%; padding: 6px; }

/* vídeos */
.videos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.videos .v.wide { grid-column: span 2; }
.videos video { width: 100%; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.videos h4 { margin: 12px 0 4px; }
.videos p { font-size: .9rem; color: var(--ink-2); }
@media (max-width: 760px) { .videos { grid-template-columns: 1fr; } .videos .v.wide { grid-column: auto; } }

/* código */
pre { background: var(--code-bg); color: var(--code-ink); border-radius: 12px; padding: 16px 18px; overflow-x: auto; font-size: .82rem; line-height: 1.6; margin: 0; position: relative; }
pre .c { color: #7f948c; }
pre .k { color: #6ff0c9; }
pre .s { color: #f5c97a; }
.codewrap { position: relative; }
.copy { position: absolute; top: 8px; right: 8px; font: 600 .72rem "Inter", sans-serif; background: rgba(255,255,255,.08); color: #dfe8e4; border: 1px solid rgba(255,255,255,.15); border-radius: 7px; padding: 4px 9px; cursor: pointer; }
.copy:hover { background: rgba(255,255,255,.16); }

/* tabelas */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td.wrap-ok { white-space: normal; }

/* gráficos */
.chartcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
section.alt .chartcard { background: var(--bg); }
.chart-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.chart-head h3 { margin: 0; }
.chart-head p { margin: 4px 0 0; font-size: .88rem; color: var(--muted); max-width: 640px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--ink-2); font: 600 .82rem "Inter", sans-serif; padding: 6px 11px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--ink-2); margin: 6px 0 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { flex: none; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { font-family: "Inter", sans-serif; fill: var(--muted); font-size: 11px; }
svg.chart .lbl { fill: var(--ink); font-weight: 600; font-size: 11.5px; }
svg.chart .axis line, svg.chart .axis path { stroke: var(--muted); }
svg.chart .gridl { stroke: var(--grid); }
.tip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 9px 12px; font-size: .82rem; line-height: 1.45; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; max-width: 280px; }
.tip.on { opacity: 1; transform: none; }
.tip b { display: block; margin-bottom: 2px; }
.linkbtn { background: none; border: 0; color: var(--accent); font: 600 .82rem "Inter", sans-serif; cursor: pointer; padding: 4px 0; }
.chart-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: .8rem; color: var(--muted); }
.datatable { margin-top: 12px; }
.datatable[hidden] { display: none; }

/* mapa de calor */
.heat { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: .84rem; }
.heat th { background: none; text-transform: none; letter-spacing: 0; font-size: .8rem; color: var(--ink-2); padding: 4px 8px; white-space: normal; border: 0; }
.heat th.rowh { text-align: right; font-weight: 500; width: 36%; }
.heat td { text-align: center; border-radius: 6px; padding: 8px 4px; font-variant-numeric: tabular-nums; font-weight: 600; border: 0; cursor: default; min-width: 64px; }
.heat td.ns { font-weight: 400; font-style: italic; }
.heat tr.grp th { text-align: left; padding-top: 14px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.scale { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.scale .bar { height: 10px; width: 180px; border-radius: 5px; }

/* KPIs */
.kpi { padding: 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
section.alt .kpi { background: var(--bg); }
.kpi b { display: block; font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .86rem; }
.kpi.good b { color: var(--accent); }
.kpi.bad b { color: var(--bad); }

/* diagrama */
.diagram { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; overflow-x: auto; }
section.alt .diagram { background: var(--bg); }
.diagram svg { min-width: 760px; width: 100%; height: auto; }
.diagram text { font-family: "Inter", sans-serif; }

/* tópicos MQTT */
.topic { font-family: "JetBrains Mono", monospace; font-size: .82rem; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.topic em { font-style: normal; color: var(--accent); }
.topic small { font-family: "Inter", sans-serif; color: var(--muted); }

/* painel embutido */
.embed { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.embed .bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: .82rem; color: var(--muted); }
.embed .bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: inline-block; }
.embed iframe { width: 100%; height: 720px; border: 0; display: block; background: #f4f5f7; }
@media (max-width: 760px) { .embed iframe { height: 560px; } }

/* QPs */
.qp { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 18px 0; border-top: 1px solid var(--line); }
.qp:first-child { border-top: 0; }
.qp .n { font-weight: 800; font-size: 1.3rem; color: var(--accent); }
.qp h4 { margin-bottom: .3em; }
.qp p { margin: 0; color: var(--ink-2); font-size: .95rem; }

/* lightbox */
.lb { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.82); display: none; place-items: center; padding: 24px; cursor: zoom-out; }
.lb.on { display: grid; }
.lb img { max-height: 90vh; max-width: 95vw; border-radius: 10px; background: #fff; }

/* rodapé */
footer { padding: 48px 0 60px; font-size: .88rem; color: var(--muted); }
footer .cols { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; }
footer h4 { color: var(--ink); font-size: .95rem; }
footer a { color: var(--ink-2); }
@media (max-width: 760px) { footer .cols { grid-template-columns: 1fr; } }

.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }
@media (forced-colors: active) { .heat td { border: 1px solid CanvasText; } }

/* diagrama da arquitetura */
.dg-box { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.5; }
.dg-acc { stroke: var(--accent); stroke-width: 2; }
.dg-t { fill: var(--ink); font-weight: 700; font-size: 17px; }
.dg-s, .dg-s text { fill: var(--ink-2); font-size: 13px; }
.dg-a { fill: var(--accent); font-size: 11.5px; font-weight: 600; }
.dg-ln { stroke: var(--accent); stroke-width: 2; fill: none; }
.dg-dash { stroke-dasharray: 5 4; }
.dg-ah { fill: var(--accent); }
.dg-bin { fill: none; stroke: var(--ink-2); stroke-width: 2; }
.dg-fill { fill: var(--pD); opacity: .85; }
.videos .v:not(.wide) video { aspect-ratio: 4 / 3; object-fit: contain; }
