/* Café Tostado — Paleta custom (Pedro) + WCAG 2.2 AAA
:
   Decisões:
   - Texto sempre em tons escuros sobre fundos claros ⇒ contraste ≥ 7:1.
   - Componentes em amarelo (brand) usam texto escuro (NUNCA branco).
   - Foco alto-contraste usando --ink-1; offset para não “pular” layout.
   - Alvos mínimos 44px; links SEMPRE sublinhados.
   - Respeito a prefers-reduced-motion.
*/

:root {
  /* Paleta solicitada */
  --bg: #f3f0ee; /* fundo principal */
  --bg-2: #efecea; /* secundário */
  --bg-3: #f3f1f3; /* frio sutil */
  --surface: #f3f0ef; /* cartões */
  --surface-2: #f4f0ee; /* variação */
  --brand: #f7d24e; /* amarelo vibrante */
  --brand-2: #f7d149; /* amarelo intenso */
  --brand-3: #f6d664; /* amarelo dourado suave */

  /* Tintas (texto) — escuras para AAA */
  --ink-1: #2b2b2b; /* texto principal (~12:1 vs claros) */
  --ink-2: #4a4a4a; /* texto secundário */
  --ink-muted: #6b6b6b; /* hints/descrições */

  /* Bordas e tokens */
  --border: #e6e1dc;
  --radius: 14px;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  --maxw: 960px;

  /* Acessibilidade */
  --focus: var(--ink-1); /* foco muito visível em qualquer fundo claro */
  --focus-bg: rgba(0, 0, 0, 0.06);

  /* Tipografia e sizing */
  --font: "Atkinson Hyperlegible", "Helvetica Neue", Arial, sans-serif;
  --fs: 16px;
  --lh: 1.8;
  --tap: 44px;
}

/* Reduz movimento, como pede a 2.2 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Base */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-1);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
}
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.2rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
}
.brand h1 {
  margin: 0;
  color: var(--ink-1);
  font-size: 1.9rem;
  font-weight: 800;
}
.brand small {
  color: var(--ink-2);
}

/* Controles / filtros */
.controls {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, 1fr) auto;
  gap: 0.6rem;
  margin: 1rem 0 1.2rem;
}
input[type="search"],
select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 1rem;
  color: var(--ink-1);
  min-height: var(--tap);
}

/* Botões — fundo amarelo com texto escuro para AAA */
button,
.btn {
  background: var(--brand);
  color: var(--ink-1); /* contraste AAA garantido com amarelo */
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8em 1.1em;
  font-size: 1rem;
  cursor: pointer;
  min-height: var(--tap);
  min-width: var(--tap);
  transition:
    background-color 0.12s ease,
    transform 0.05s ease,
    border-color 0.12s ease;
  box-shadow: var(--shadow);
}
button:hover,
.btn:hover {
  background: var(--brand-2);
  border-color: #d9caa9;
}
button:active,
.btn:active {
  transform: translateY(1px);
}
.btn-secundario {
  background: var(--brand-3);
  color: var(--ink-1);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-1);
  border: 1.5px solid var(--border);
}

/* Foco muito visível */
:focus {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}
:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

/* Links — sempre sublinhados (não dependem de cor para distinguir) */
a {
  color: var(--ink-1);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.12em;
}
a:hover,
a:focus {
  background: var(--focus-bg);
  border-radius: 4px;
}

/* Grid de cartões */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.card h3 {
  margin: 0.2rem 0 0.4rem;
  color: var(--ink-1);
  font-size: 1.25rem;
  font-weight: 800;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  font-size: 0.95rem;
  color: var(--ink-2);
}
.badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  color: var(--ink-1);
}
.note {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  color: var(--ink-1);
}

/* Estrelas — texto escuro para contraste AAA */
.stars {
  display: inline-flex;
  gap: 0.25rem;
  font-size: 1.2rem;
  color: var(--ink-1);
}

/* Detalhes expansíveis */
.details-block summary {
  list-style: none;
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  border: 2px solid var(--border);
  color: var(--ink-1);
  background: var(--bg-3);
  cursor: pointer;
  min-height: var(--tap);
}
.details-block[open] summary {
  background: var(--focus-bg);
  border-color: var(--focus);
}
.details-block summary::marker {
  content: "";
}

.detail-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.5rem 0.9rem;
}
.dl-row {
  display: contents;
}
.dl-term {
  font-weight: 800;
  color: var(--ink-1);
}
.dl-def {
  color: var(--ink-1);
}

/* Tabela acessível (avaliações por método) */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  margin-top: 0.6rem;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  color: var(--ink-1);
}
.tbl caption {
  text-align: left;
  font-weight: 800;
  color: var(--ink-1);
  padding: 0.6rem 0.8rem;
}
.tbl th,
.tbl td {
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.8rem;
  text-align: left;
  vertical-align: top;
}
.tbl thead th {
  background: var(--bg-2);
  position: sticky;
  top: 0;
}

/* Caixas de status e vazios */
.box-claro {
  background: var(--bg-3);
  border: 2px solid var(--border);
  color: var(--ink-1);
  padding: 1em;
  border-radius: 10px;
  margin: 1em 0;
}
#status[data-warn="true"] {
  border-color: #7a2e2e;
  background: #fff2f2;
  color: #351616;
}

/* Rodapé */
.footnote {
  margin: 2rem 0 1rem;
  color: var(--ink-2);
  font-size: 0.95rem;
}

/* Responsivo */
@media (max-width: 900px) {
  .controls {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: auto;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Acessório: elementos “visually hidden” */
.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;
}

/* Links que envolvem cards na vitrine */
.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-link .card {
  transition:
    transform 0.08s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}

.card-link:hover .card,
.card-link:focus-visible .card {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  border-color: var(--focus);
}

/* Pequeno destaque para o "Ver post deste café" */
.card-link-cta {
  margin-top: 0.6rem;
  font-size: 0.95rem;
}

.card-link-cta span {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
