/* Confraria da Mata · Guia de estilos BJCP 2021 — mesmo tema da calculadora (ver ../calculadora/DESIGN.md).
   Tokens em três camadas: primitivos (cores do brasão) → semânticos (bg, ink, primary…) → componentes.
   Papéis de cor: dourado = interação e navegação; verde-claro = dado (faixas e valores); creme = texto. */
@font-face { font-family: "Barlow"; src: url("../assets/fonts/barlow-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../assets/fonts/barlow-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("../assets/fonts/barlow-condensed-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("../assets/fonts/barlow-condensed-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Permanent Marker"; src: url("../assets/fonts/permanent-marker-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --preto: #0a0a0a;
  --preto-2: #121311;
  --preto-3: #1a1c18;
  --creme: #f3ead3;
  --creme-2: #b9b39f;
  --verde: #4fb536;
  --verde-claro: #8fe34a;
  --dourado: #f2b632;
  --dourado-claro: #ffc94a;
  --vermelho: #ff7a62;

  --bg: var(--preto);
  --surface: var(--preto-2);
  --surface-2: var(--preto-3);
  --line: rgba(243, 234, 211, 0.12);
  --line-strong: rgba(243, 234, 211, 0.26);
  --ink: var(--creme);
  --muted: var(--creme-2);
  --primary: var(--dourado);
  --primary-strong: var(--dourado-claro);
  --primary-soft: rgba(242, 182, 50, 0.16);
  --on-primary: var(--preto);
  --accent: var(--verde-claro);
  --accent-deep: var(--verde);
  --bad: var(--vermelho);
  --bad-soft: rgba(255, 122, 98, 0.14);

  --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --display: "Permanent Marker", "Brush Script MT", cursive;
  --fs-xs: 0.8rem;
  --fs-sm: 0.9rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.8rem;
  --fs-3xl: 2.15rem;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 180ms;

  --z-backdrop: 19; --z-nav: 20; --z-topbar: 30;
  --topbar-h: 62px;
  --nav-w: 292px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-kerning: normal;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; font-weight: 600; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--on-primary); padding: 8px 12px; border-radius: var(--r-md); z-index: 100; font-weight: 600; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- casca ---- */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "top top" "nav main";
  min-height: 100dvh;
}
.topbar {
  grid-area: top;
  position: sticky; top: 0; z-index: var(--z-topbar);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-5);
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); color: var(--ink); text-decoration: none; min-width: 0; }
.brand-mark { color: var(--accent); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.12; min-width: 0; }
.brand-name { font-family: var(--cond); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; }
.brand-sub { font-family: var(--cond); font-weight: 500; font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-5); }
.brand-site { font-family: var(--cond); font-weight: 500; font-size: var(--fs-sm); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); text-decoration: none; transition: color var(--dur) var(--ease); }
.brand-site:hover { color: var(--ink); }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink);
  transition: background var(--dur) var(--ease);
}
.btn-icon:hover { background: var(--surface-2); }
.nav-toggle { display: none; margin-left: -8px; }

.nav {
  grid-area: nav;
  position: sticky; top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: var(--sp-4) var(--sp-3) var(--sp-6);
}
.nav-group { margin-bottom: var(--sp-4); }
.nav-group-title { font-family: var(--cond); font-size: var(--fs-xs); font-weight: 700; color: var(--primary); letter-spacing: 0.14em; text-transform: uppercase; padding: var(--sp-2) var(--sp-3); }
.nav a {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2);
  padding: 9px var(--sp-3); border-radius: var(--r-md);
  color: var(--ink); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; line-height: 1.3;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.nav a .abbr { font-family: var(--cond); font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0.04em; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.nav a[aria-current="page"] .abbr, .nav a[aria-current="page"] .nav-num { color: rgba(10, 10, 10, 0.72); }
.nav-num { font-family: var(--cond); font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; display: inline-block; min-width: 1.9em; }
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: var(--z-backdrop); }

.main { grid-area: main; padding: var(--sp-6) var(--sp-6) var(--sp-8); min-width: 0; }
.main:focus { outline: none; }
.wrap { max-width: 1100px; margin: 0 auto; }

/* ---- cabeçalho de página ---- */
.page-head { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-5); max-width: 76ch; }
.page-head--wide { max-width: none; }
.kicker { font-family: var(--cond); font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--primary); }
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { text-decoration: underline; }
/* caixa normal de propósito: os nomes dos estilos ficam como no guia */
.page-head h1 { font-family: var(--cond); font-weight: 700; letter-spacing: 0.01em; font-size: var(--fs-3xl); line-height: 1.05; }
.page-head h1 em { font-family: var(--display); font-style: normal; font-weight: 400; letter-spacing: 0; color: var(--accent); font-size: 1.05em; margin-right: 0.4em; }
.page-head h1.home-title { font-family: var(--display); font-weight: 400; letter-spacing: 0; }
.lead { color: var(--muted); font-size: var(--fs-md); text-wrap: pretty; }
.lead--notas { max-width: 76ch; }

/* ---- busca ---- */
.search { position: relative; display: flex; align-items: center; max-width: 680px; }
.search-icon { position: absolute; left: 16px; display: inline-flex; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 52px; padding: 0 var(--sp-4) 0 48px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  font-size: var(--fs-lg); font-weight: 500;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.search input:hover { border-color: rgba(242, 182, 50, 0.55); }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: var(--preto); }
.search input::placeholder { color: var(--muted); opacity: 0.8; }
.search input::-webkit-search-cancel-button { filter: invert(0.85) sepia(0.2); cursor: pointer; }

.results-bar { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; margin: var(--sp-4) 0 var(--sp-5); color: var(--muted); font-size: var(--fs-sm); min-height: 36px; }
.results-count strong { color: var(--ink); font-weight: 500; font-size: var(--fs-md); }

/* ---- filtros por atributo ---- */
details.facets { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); margin-top: var(--sp-4); }
details.facets summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 var(--sp-4);
  font-family: var(--cond); font-weight: 700; font-size: var(--fs-sm); letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary);
}
details.facets summary::-webkit-details-marker { display: none; }
details.facets summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform var(--dur) var(--ease); margin-left: 2px; }
details.facets[open] summary::before { transform: rotate(45deg); }
.facets-body { display: grid; gap: var(--sp-4); padding: 0 var(--sp-4) var(--sp-4); }
.facet { display: grid; gap: var(--sp-2); }
.facet-title { font-family: var(--cond); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
  font-family: var(--cond); font-weight: 500; font-size: var(--fs-sm); letter-spacing: 0.03em; line-height: 1.1;
  cursor: pointer; text-decoration: none; text-align: left;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:hover { border-color: var(--primary); }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; font-size: var(--fs-xs); }
.chip[aria-pressed="true"] .n, .chip[aria-pressed="true"] .x { color: rgba(10, 10, 10, 0.72); }
.chip:disabled { opacity: 0.38; cursor: not-allowed; }
.chip:disabled:hover { border-color: var(--line-strong); }
.chip--x .x { font-size: 1.1em; line-height: 1; }
.chip--static { cursor: default; border-color: var(--line); color: var(--creme); font-family: var(--font); font-size: var(--fs-sm); letter-spacing: 0; }
.chip--static:hover { border-color: var(--line); }

/* ---- lista de estilos ---- */
.cat-group { margin-bottom: var(--sp-6); display: grid; gap: var(--sp-3); }
.cat-group h2 { font-family: var(--cond); font-size: var(--fs-md); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--primary); display: flex; gap: var(--sp-3); align-items: baseline; flex-wrap: wrap; }
.cat-group h2 a { color: inherit; text-decoration: none; }
.cat-group h2 a:hover { text-decoration: underline; }
.cat-group h2 .n { color: var(--muted); font-weight: 500; font-size: var(--fs-sm); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.lista { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card {
  display: grid; grid-template-columns: 54px minmax(0, 1fr); grid-template-rows: auto auto; gap: 4px var(--sp-3); align-items: start;
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  color: var(--ink); text-decoration: none;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card:hover { border-color: rgba(242, 182, 50, 0.6); background: var(--surface-2); transform: translateY(-2px); }
.card-id { grid-row: 1 / span 2; font-family: var(--cond); font-weight: 700; font-size: var(--fs-lg); color: var(--primary); letter-spacing: 0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.card-name { font-family: var(--cond); font-weight: 700; font-size: var(--fs-lg); line-height: 1.15; letter-spacing: 0.01em; }
.card-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; align-items: center; }
.card-stats .k { font-family: var(--cond); font-weight: 700; letter-spacing: 0.06em; margin-right: 4px; }
.card-stats .nota { font-style: italic; }
.mini-swatch { width: 26px; height: 11px; border-radius: 3px; border: 1px solid rgba(243, 234, 211, 0.25); display: inline-block; vertical-align: -1px; }

/* ---- página do estilo ---- */
.estilo-body { display: grid; gap: var(--sp-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 960px) {
  .estilo-body { grid-template-columns: minmax(0, 1fr) 340px; }
  .estilo-side { position: sticky; top: calc(var(--topbar-h) + var(--sp-5)); }
}
@media (max-width: 959px) {
  .estilo-side { order: -1; }
}
.estilo-main { min-width: 0; }
.secoes { display: grid; gap: var(--sp-5); max-width: 72ch; }
.secao h2 { font-family: var(--cond); font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--primary); margin-bottom: var(--sp-2); }
.secao p { text-wrap: pretty; color: var(--creme); line-height: 1.6; }
.secao .chips { margin-bottom: var(--sp-2); }
.hint { font-size: var(--fs-xs); color: var(--muted); text-wrap: pretty; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-5); display: grid; gap: var(--sp-4); min-width: 0;
  box-shadow: 0 24px 48px -32px rgba(143, 227, 74, 0.25);
}
.panel h2 { font-family: var(--cond); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--primary); }
.stat { display: grid; gap: 6px; }
.stat-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.stat-name { font-family: var(--cond); font-weight: 700; letter-spacing: 0.06em; color: var(--muted); font-size: var(--fs-sm); }
.stat-val { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--accent); font-size: var(--fs-md); }
.stat-track { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.stat-fill { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 5px; }
.stat--srm .stat-track { height: 14px; border-radius: 4px; }
.stat--srm .stat-fill { background: transparent; border: 2px solid var(--creme); border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.7); }
.stat-scale { display: flex; justify-content: space-between; font-family: var(--cond); font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.stat-nota { font-size: var(--fs-sm); color: var(--creme); text-wrap: pretty; }
.swatch-range { height: 44px; border-radius: var(--r-md); border: 1px solid rgba(243, 234, 211, 0.18); }

/* ---- anterior / próximo ---- */
.pager { display: flex; justify-content: space-between; gap: var(--sp-4); margin-top: var(--sp-7); padding-top: var(--sp-5); border-top: 1px solid var(--line); }
.pager a { display: grid; gap: 2px; text-decoration: none; color: var(--ink); max-width: 48%; }
.pager a .k { font-family: var(--cond); font-size: var(--fs-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.pager a .v { font-family: var(--cond); font-weight: 700; font-size: var(--fs-md); line-height: 1.2; }
.pager a.next { text-align: right; margin-left: auto; }
.pager a:hover .v { color: var(--primary); }

/* ---- botões, avisos, rodapé ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 var(--sp-4); border-radius: var(--r-md); cursor: pointer;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink); font-family: var(--cond); font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn--ghost { border-color: transparent; color: var(--primary); }
.btn--ghost:hover { background: var(--primary-soft); border-color: transparent; }
.btn--sm { height: 34px; padding: 0 12px; font-size: var(--fs-xs); }
.notice { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--surface); font-size: var(--fs-sm); color: var(--ink); border: 1px solid var(--line); text-wrap: pretty; }
.notice.tone-bad { background: var(--bad-soft); border-color: rgba(255, 122, 98, 0.3); }
.loading { color: var(--muted); }
.empty { padding: var(--sp-6); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--muted); text-align: center; text-wrap: pretty; }
.foot { margin-top: var(--sp-8); padding-top: var(--sp-5); border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--muted); max-width: 76ch; text-wrap: pretty; display: grid; gap: var(--sp-2); }
.foot a { color: var(--primary); }

/* ---- responsivo ---- */
@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .nav-toggle { display: inline-flex; }
  .nav {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: min(var(--nav-w), 86vw);
    z-index: var(--z-nav); transform: translateX(-100%); transition: transform var(--dur) var(--ease);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.6);
  }
  body.nav-open .nav { transform: translateX(0); }
  .main { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
  .topbar { padding: 0 var(--sp-4); }
  .brand-sub, .brand-site { display: none; }
  .page-head h1 { font-size: var(--fs-2xl); }
  .lista { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .brand-name { font-size: var(--fs-sm); }
  .search input { font-size: var(--fs-md); padding-left: 44px; }
  .pager a { max-width: 100%; }
  .pager { flex-direction: column; }
  .pager a.next { text-align: left; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --ink: #111; --muted: #444; --line: #ccc; --line-strong: #999; --accent: #2f7d1f; --primary: #8a5a00; }
  .topbar, .nav, .backdrop, .skip, .pager, details.facets, .search, .results-bar { display: none !important; }
  .app { display: block; }
  .estilo-side { position: static; }
  .panel { box-shadow: none; }
}
