/* ============================================================
   mesaregulavel.tn1.top — Design system (workshop editorial)
   Self-contained. Tema claro/escuro via prefers-color-scheme.
   ============================================================ */

:root {
  --paper:      #F6F1E7;
  --paper-2:    #FBF8F1;
  --ink:        #1C1813;
  --ink-2:      #4A4238;
  --ink-3:      #746A5B;
  --line:       #E2D9C7;
  --line-2:     #D0C4AC;
  --accent:     #C0521C;   /* laranja queimado (metal aquecido) */
  --accent-ink: #8F3A12;
  --accent-2:   #3F6B4E;   /* verde bancada */
  --accent-2-ink:#2C4E38;
  --wood:       #A9713C;
  --card:       #FFFFFF;
  --shadow:     0 1px 2px rgba(28,24,19,.06), 0 8px 24px rgba(28,24,19,.07);
  --shadow-sm:  0 1px 2px rgba(28,24,19,.08);
  --radius:     14px;
  --radius-sm:  9px;
  --maxw:       1080px;
  --font-body:  'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head:  'Fraunces', Georgia, 'Times New Roman', serif;
  --font-mono:  ui-monospace, 'SFMono-Regular', 'Menlo', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #17140F;
    --paper-2: #1E1A14;
    --ink:     #ECE5D8;
    --ink-2:   #C3BAA9;
    --ink-3:   #948A78;
    --line:    #2E281F;
    --line-2:  #3C3527;
    --accent:  #E67A3C;
    --accent-ink:#F0996A;
    --accent-2:#6FA982;
    --accent-2-ink:#8BC49E;
    --wood:    #C99257;
    --card:    #201B14;
    --shadow:  0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12% -8%, rgba(192,82,28,.06), transparent 42%),
    radial-gradient(circle at 92% 4%, rgba(63,107,78,.06), transparent 40%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Tipografia ---- */
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.15; color: var(--ink); margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin-top: 2.2rem; }
h3 { font-size: 1.28rem; margin-top: 1.6rem; }
h4 { font-size: 1.06rem; font-family: var(--font-body); font-weight: 700; letter-spacing: .01em; }
p { margin: 0 0 1rem; }
a { color: var(--accent-ink); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
strong { color: var(--ink); font-weight: 700; }
small { color: var(--ink-3); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
::selection { background: rgba(192,82,28,.18); }

/* ---- Layout ---- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.prose { max-width: 760px; }
.section { padding: 2.4rem 0; }
main { display: block; }

/* ---- Top bar / nav ---- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__in { display: flex; align-items: center; gap: 1rem; height: 60px; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--font-head); font-weight: 600; font-size: 1.12rem; color: var(--ink); text-decoration: none; margin-right: auto; }
.brand__mark { width: 26px; height: 26px; flex: 0 0 auto; }
.nav__links { display: flex; gap: .3rem; align-items: center; }
.nav__links a {
  color: var(--ink-2); text-decoration: none; font-size: .93rem; font-weight: 500;
  padding: .4rem .6rem; border-radius: 8px;
}
.nav__links a:hover { color: var(--ink); background: color-mix(in srgb, var(--line) 55%, transparent); }
.nav__links a[aria-current="page"] { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.nav__toggle { display: none; background: none; border: 1px solid var(--line-2); border-radius: 8px; width: 40px; height: 36px; cursor: pointer; color: var(--ink); font-size: 1.1rem; }

@media (max-width: 820px) {
  .nav__toggle { display: block; }
  .nav__links {
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper-2); border-bottom: 1px solid var(--line);
    padding: .5rem 12px 1rem; box-shadow: var(--shadow);
    display: none;
  }
  .nav__links.open { display: flex; }
  .nav__links a { padding: .7rem .6rem; font-size: 1rem; }
}

/* ---- Hero ---- */
.hero { padding: 3.4rem 0 1.4rem; }
.hero .eyebrow { display: inline-block; font-family: var(--font-mono); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 12%, transparent); padding: .3rem .6rem; border-radius: 999px; margin-bottom: 1rem; }
.hero h1 { max-width: 16ch; }
.hero .lede { font-size: clamp(1.05rem, 2.2vw, 1.28rem); color: var(--ink-2); max-width: 62ch; }

/* ---- Botões ---- */
.btn { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; font-size: .95rem; text-decoration: none; padding: .62rem 1.05rem; border-radius: 999px; border: 1px solid transparent; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { color: #fff; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn--ghost:hover { background: color-mix(in srgb, var(--line) 50%, transparent); color: var(--ink); }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.4rem; }

/* ---- Cards / grid ---- */
.grid { display: grid; gap: 1.1rem; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid--3, .grid--4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.35rem; box-shadow: var(--shadow-sm); }
.card--link { text-decoration: none; color: inherit; display: block; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.card--link:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); color: inherit; }
.card h3 { margin-top: 0; }
.card__num { font-family: var(--font-head); font-size: 1.7rem; color: var(--accent); line-height: 1; }
.card__tag { display: inline-block; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* Card de família de mecanismo (numerada) */
.family { position: relative; padding-left: 1.35rem; }
.family::before { content: ""; position: absolute; left: 0; top: .3rem; bottom: .3rem; width: 4px; border-radius: 4px; background: var(--accent); }
.family--2::before { background: var(--accent-2); }
.family--3::before { background: var(--wood); }
.family--4::before { background: var(--ink-2); }

/* ---- Callouts ---- */
.callout { border-left: 4px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--card)); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 1rem 1.2rem; margin: 1.4rem 0; }
.callout--tip { border-left-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 8%, var(--card)); }
.callout--warn { border-left-color: #C99A2E; background: color-mix(in srgb, #C99A2E 9%, var(--card)); }
.callout p:last-child { margin-bottom: 0; }
.callout__title { font-weight: 700; display: block; margin-bottom: .2rem; }

/* ---- Tabelas ---- */
.table-wrap { overflow-x: auto; margin: 1.3rem 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 520px; }
thead th { text-align: left; font-family: var(--font-body); font-weight: 700; font-size: .82rem; letter-spacing: .02em; text-transform: uppercase; color: var(--ink-3); background: var(--paper-2); padding: .7rem .9rem; border-bottom: 1px solid var(--line-2); }
tbody td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--line) 30%, transparent); }

/* ---- Listas ---- */
.prose ul, .prose ol { padding-left: 1.2rem; margin: 0 0 1rem; }
.prose li { margin: .35rem 0; }
.checklist { list-style: none; padding: 0; }
.checklist li { position: relative; padding-left: 1.7rem; margin: .55rem 0; }
.checklist li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--accent-2-ink); font-weight: 700; }

/* ---- Pills / badges ---- */
.pill { display: inline-block; font-size: .76rem; font-weight: 600; padding: .16rem .55rem; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--paper-2); }
.pill--cost { color: var(--accent-2-ink); border-color: color-mix(in srgb, var(--accent-2) 40%, var(--line-2)); }
.pill--hard { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 40%, var(--line-2)); }
.meta-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .2rem; }

/* ---- Build item (catálogo) ---- */
.build { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 1.15rem 1.25rem; box-shadow: var(--shadow-sm); }
.build h3 { margin: 0 0 .3rem; font-size: 1.12rem; }
.build .src { font-size: .85rem; }

/* ---- Filtros (builds) ---- */
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1.2rem 0; }
.filter-btn { font: inherit; font-size: .86rem; font-weight: 600; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line-2); background: var(--paper-2); color: var(--ink-2); cursor: pointer; }
.filter-btn[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.is-hidden { display: none !important; }

/* ---- Índice de página (TOC) ---- */
.toc { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper-2); padding: 1rem 1.2rem; margin: 1.4rem 0; }
.toc strong { display: block; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: .5rem; }
.toc ol { margin: 0; padding-left: 1.1rem; columns: 2; }
@media (max-width: 620px) { .toc ol { columns: 1; } }
.toc a { text-decoration: none; color: var(--ink-2); }
.toc a:hover { color: var(--accent); }

/* ---- Page header ---- */
.page-head { padding: 2.6rem 0 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; }
.page-head .eyebrow { font-family: var(--font-mono); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); }
.breadcrumb { font-size: .85rem; color: var(--ink-3); margin-bottom: .6rem; }
.breadcrumb a { color: var(--ink-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

/* ---- Footer ---- */
.footer { border-top: 1px solid var(--line); margin-top: 3rem; padding: 2rem 0 3rem; color: var(--ink-3); font-size: .9rem; }
.footer a { color: var(--ink-2); }
.footer__grid { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: space-between; }

/* ---- Back to top ---- */
.totop { position: fixed; right: 18px; bottom: 18px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font-size: 1.1rem; cursor: pointer; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 40; }
.totop.show { opacity: 1; pointer-events: auto; }

/* ---- utilitários ---- */
.center { text-align: center; }
.muted { color: var(--ink-3); }
.lead { font-size: 1.12rem; color: var(--ink-2); }
.stat-row { display: flex; flex-wrap: wrap; gap: 1.4rem; margin: 1.4rem 0; }
.stat { }
.stat b { display: block; font-family: var(--font-head); font-size: 1.9rem; color: var(--accent); line-height: 1; }
.stat span { font-size: .85rem; color: var(--ink-3); }
/* ---- Imagens / figuras / diagramas ---- */
img { max-width: 100%; height: auto; }
figure.fig { margin: 1.7rem 0; }
.fig > img, .fig > svg, .fig > .plate { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); box-shadow: var(--shadow-sm); }
.fig figcaption { font-size: .86rem; color: var(--ink-3); margin-top: .55rem; text-align: center; }
.fig--tight > img, .fig--tight > svg { max-width: 520px; margin: 0 auto; }
.fig-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(2, 1fr); margin: 1.6rem 0; }
@media (max-width: 640px) { .fig-grid { grid-template-columns: 1fr; } }
.fig-grid figure { margin: 0; }

/* Hero com ilustração */
.hero--art { display: grid; grid-template-columns: 1.15fr .85fr; gap: 2rem; align-items: center; }
.hero--art .hero__art { width: 100%; height: auto; }
@media (max-width: 820px) { .hero--art { grid-template-columns: 1fr; } .hero--art .hero__art { max-width: 420px; } }

/* Embed de vídeo (YouTube) — responsivo 16:9 */
.embed { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-sm); margin: 1rem 0; background: #000; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Card de build com miniatura + link "fotos na fonte" */
.build__thumb { width: 100%; height: 150px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: .8rem; border: 1px solid var(--line); background: var(--paper-2); display: block; }
.build__thumb--pad { object-fit: contain; padding: .6rem; }
.src-media { display: inline-flex; align-items: center; gap: .45rem; font-size: .88rem; font-weight: 600; text-decoration: none; color: var(--accent-ink); margin-top: .5rem; padding: .4rem .7rem; border: 1px solid var(--line-2); border-radius: 999px; background: var(--paper-2); }
.src-media:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
.src-media svg { width: 15px; height: 15px; flex: 0 0 auto; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; transition: none !important; } }
