/* ==========================================================================
   Biblioteca do Galinheiro — Área de Membros
   Design system: cores, tipografia e espaçamentos em variáveis no :root.
   ========================================================================== */

:root {
  /* Fundos */
  --bg-primary: #100F0B;
  --bg-secondary: #17150F;
  --surface: #1D1A13;
  --surface-hover: #25211A;
  --surface-raised: #2B261D;

  /* Marca */
  --brown: #2A1A0F;
  --brown-deep: #3D2312;
  --cream: #FAF0DF;
  --cream-light: #FCF8F1;
  --gold: #F2A007;
  --gold-secondary: #E0840E;
  --green: #294626;
  --green-secondary: #3F5D38;
  --terracotta: #A84B32;

  /* Texto (alto contraste sobre os fundos escuros) */
  --text: #FAF0DF;
  --text-strong: #FCF8F1;
  --text-muted: #D3C7B0;
  --text-on-gold: #1A1206;

  /* Linhas */
  --border: #352E22;
  --border-strong: #4A4132;

  /* Tipografia */
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Forma e espaço */
  --radius: 12px;
  --radius-sm: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 18px rgba(0, 0, 0, .18);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 14px 30px rgba(0, 0, 0, .28);
  --focus: 0 0 0 3px var(--bg-primary), 0 0 0 6px var(--gold);
  --ease: cubic-bezier(.2, .7, .3, 1);
  --t: 200ms;

  --sidebar-w: 264px;
  --rail-w: 104px;
  --topbar-h: 68px;

  color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem; /* 17px */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.2;
  margin: 0;
  letter-spacing: -.005em;
}

p { margin: 0; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
svg { flex: none; }

[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 16px; top: -100px;
  z-index: 100;
  background: var(--gold);
  color: var(--text-on-gold);
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.skip-link:focus { top: 16px; }

/* ---------- Layout ---------- */

.layout { min-height: 100vh; }

.main {
  margin-left: var(--sidebar-w);
  padding: 40px clamp(24px, 4vw, 56px) 48px;
  max-width: calc(var(--sidebar-w) + 1240px);
}
.main:focus { box-shadow: none; }

/* ---------- Marca ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-strong);
  text-decoration: none;
  min-height: 48px;
}
.brand-logo {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--brown-deep);
  border: 1px solid var(--border-strong);
  color: var(--gold);
}
.brand-logo svg { width: 28px; height: 28px; }
.brand-text {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.2;
}

/* ---------- Menu lateral ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 18px 24px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 40;
}

.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding-inline: 6px; }

.nav ul { display: flex; flex-direction: column; gap: 6px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item:hover { background: var(--surface-hover); color: var(--text-strong); }

.nav-item.is-active {
  background: var(--surface-raised);
  color: var(--text-strong);
  font-weight: 600;
}
.nav-item.is-active svg { color: var(--gold); }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--gold);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.menu-close, .menu-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-strong);
  font-size: 1rem;
  font-weight: 600;
  transition: background-color var(--t) var(--ease);
}
.menu-close svg, .menu-toggle svg { width: 22px; height: 22px; }
.menu-close:hover, .menu-toggle:hover { background: var(--surface-hover); }

.topbar { display: none; }
.backdrop { display: none; }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  align-items: stretch;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(28px, 4vw, 48px);
}

.hero h1 { font-size: clamp(1.75rem, 2.6vw, 1.875rem); /* 28–30px */ }

.hero-sub {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--cream);
}

.hero-desc {
  max-width: 52ch;
  color: var(--text-muted);
}

.hero-count {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  margin-top: 6px;
  padding: 8px 16px 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-strong);
}
.hero-count svg { width: 20px; height: 20px; color: var(--gold); }

.hero-media {
  position: relative;
  min-height: 260px;
  background: var(--green);
}
.hero-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Overlay escuro discreto, que funde a foto com o fundo do bloco */
.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--bg-secondary) 0%, rgba(23, 21, 15, .35) 28%, rgba(16, 15, 11, .18) 100%);
  pointer-events: none;
}

/* ---------- Imagens com fallback (placeholder nas cores da marca) ---------- */

img[data-fallback] { opacity: 0; transition: opacity 300ms var(--ease); }
img[data-fallback].is-loaded { opacity: 1; }
img[data-fallback].is-broken { display: none; }

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background-color: var(--tone, var(--green));
  background-image:
    radial-gradient(120% 90% at 70% 20%, rgba(250, 240, 223, .07), transparent 60%),
    repeating-linear-gradient(135deg, rgba(250, 240, 223, .025) 0 2px, transparent 2px 14px);
  color: rgba(250, 240, 223, .5);
}
.placeholder svg { width: 72px; height: 72px; }
.hero-media .placeholder svg { width: 96px; height: 96px; color: rgba(242, 160, 7, .45); }

/* ---------- Meus Materiais ---------- */

.materiais { margin-top: 56px; }

.materiais-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
}
.materiais-head h2 { font-size: 1.625rem; /* 26px */ }

.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  flex: 1 1 520px;
  justify-content: flex-end;
}

.campo { position: relative; }
.campo--busca { flex: 1 1 280px; max-width: 380px; }
.campo--select { flex: 0 1 230px; }

.campo input,
.campo select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--text-strong);
  font-size: 1rem;
  transition: border-color var(--t) var(--ease), background-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.campo input { padding: 12px 16px 12px 48px; -webkit-appearance: none; appearance: none; }
.campo input::placeholder { color: #B5A98F; opacity: 1; }
.campo input::-webkit-search-cancel-button { -webkit-appearance: none; }
.campo > svg {
  position: absolute;
  left: 16px; top: 50%;
  width: 22px; height: 22px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.campo select {
  padding: 12px 48px 12px 16px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FAF0DF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 22px;
}
.campo select option { background: var(--bg-secondary); color: var(--text-strong); }

.campo input:hover, .campo select:hover { background-color: var(--surface-hover); }
.campo input:focus-visible,
.campo select:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 160, 7, .35);
  border-radius: var(--radius);
}

.resultado {
  margin-top: 14px;
  min-height: 1.6em;
  font-size: .9375rem;
  color: var(--text-muted);
}

/* ---------- Grid de cards ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-top: 12px;
}
@media (min-width: 640px)  { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; } }

/* ---------- Card ---------- */

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}
.card:hover,
.card:focus-within {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

.card-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--brown);
  overflow: hidden;
}
.card-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(16, 15, 11, .35) 100%);
  pointer-events: none;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  padding: 22px 22px 24px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--green);
  border: 1px solid var(--green-secondary);
  color: var(--cream-light);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.5;
}
.badge--bonus { background: var(--terracotta); border-color: #C0634A; }

.card-formato {
  font-size: .875rem;
  color: var(--text-muted);
}

.card-title { font-size: 1.375rem; /* 22px */ line-height: 1.25; }

.card-desc { color: var(--text-muted); font-size: 1rem; line-height: 1.6; }

/* Progresso */
.progresso { margin-top: auto; padding-top: 6px; }
.progresso-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--text-muted);
}
.progresso-label svg { width: 18px; height: 18px; }
.progresso[data-status="concluido"] .progresso-label { color: #A9CF9C; font-weight: 600; }
.progresso[data-status="iniciado"] .progresso-label { color: var(--cream); }

.barra {
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  overflow: hidden;
}
.barra-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--gold);
  transition: width 400ms var(--ease);
}
.progresso[data-status="concluido"] .barra-fill { background: #6E9A60; }

.card-acoes { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 14px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease), border-color var(--t) var(--ease), transform var(--t) var(--ease);
}
.btn svg { width: 20px; height: 20px; transition: transform var(--t) var(--ease); }

.btn-primario {
  width: 100%;
  background: var(--gold);
  color: var(--text-on-gold);
}
.btn-primario:hover { background: var(--gold-secondary); }
.btn-primario:hover svg { transform: translateX(3px); }
.btn-primario:active { transform: translateY(1px); }

.btn-secundario {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-strong);
}
.btn-secundario:hover { background: var(--surface-hover); border-color: var(--text-muted); }

.btn-texto {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: .9375rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 4px;
  transition: color var(--t) var(--ease), background-color var(--t) var(--ease);
}
.btn-texto svg { width: 18px; height: 18px; }
.btn-texto:hover { color: var(--text-strong); background: var(--surface-hover); text-decoration-color: currentColor; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.link:hover { color: #FFC24A; }

/* ---------- Estado vazio e avisos ---------- */

.vazio {
  margin-top: 12px;
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
}
.vazio-titulo { font-family: var(--font-serif); font-size: 1.375rem; font-weight: 600; color: var(--text-strong); }
.vazio-texto { margin: 8px auto 20px; max-width: 46ch; color: var(--text-muted); }

.aviso {
  margin-top: 12px;
  padding: 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}

/* ---------- Rodapé ---------- */

.rodape {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  font-size: .9375rem;
  color: var(--text-muted);
}

/* ---------- Aviso flutuante ("em breve") ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 12px 12px 20px;
  transform: translateX(-50%);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  color: var(--text-strong);
  font-size: 1rem;
  animation: toast-in var(--t) var(--ease);
}
.toast[hidden] { display: none; }
.toast-fechar {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
}
.toast-fechar:hover { background: var(--surface-hover); color: var(--text-strong); }
.toast-fechar svg { width: 20px; height: 20px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ==========================================================================
   Responsivo
   ========================================================================== */

/* Desktop médio: menos respiro lateral */
@media (max-width: 1279px) {
  .hero { grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); }
}

/* Tablet: menu reduzido (ícone com o nome embaixo) */
@media (max-width: 1099px) {
  .sidebar {
    width: var(--rail-w);
    padding: 20px 10px;
    gap: 20px;
    align-items: stretch;
  }
  .sidebar-head { justify-content: center; padding: 0; }
  .sidebar .brand-text { display: none; }
  .nav-item {
    flex-direction: column;
    gap: 6px;
    min-height: 72px;
    padding: 10px 4px;
    font-size: .8125rem;
    line-height: 1.25;
    text-align: center;
    justify-content: center;
  }
  .nav-item.is-active::before { top: 16px; bottom: 16px; }
  .main { margin-left: var(--rail-w); }
}

/* Celular: barra superior + menu recolhível */
@media (max-width: 767px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand-logo { width: 40px; height: 40px; }
  .menu-toggle, .menu-close { display: inline-flex; }

  .sidebar {
    width: min(320px, 86vw);
    padding: 20px 16px 24px;
    gap: 24px;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 250ms var(--ease), visibility 0s linear 250ms;
    z-index: 50;
    box-shadow: var(--shadow-hover);
  }
  .sidebar.is-open {
    transform: none;
    visibility: visible;
    transition: transform 250ms var(--ease), visibility 0s;
  }
  .sidebar-head { justify-content: space-between; }
  .sidebar .brand-text { display: inline; }
  .nav-item {
    flex-direction: row;
    gap: 14px;
    min-height: 52px;
    padding: 12px 16px;
    font-size: 1rem;
    text-align: left;
    justify-content: flex-start;
  }
  .nav-item.is-active::before { top: 12px; bottom: 12px; }

  .backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: block;
    background: rgba(8, 7, 5, .7);
  }
  .backdrop[hidden] { display: none; }

  .main { margin-left: 0; padding: 20px 16px 40px; }

  .hero { grid-template-columns: 1fr; }
  .hero-media { order: -1; min-height: 0; aspect-ratio: 16 / 7; }
  .hero-media::after { background: linear-gradient(0deg, var(--bg-secondary) 0%, rgba(23, 21, 15, .2) 45%, rgba(16, 15, 11, .15) 100%); }
  .hero-text { padding: 22px 20px 26px; }
  .hero-sub { font-size: 1.125rem; }

  .materiais { margin-top: 40px; }
  .materiais-head h2 { font-size: 1.5rem; }
  .filtros { flex-basis: 100%; }
  .campo--busca, .campo--select { flex: 1 1 100%; max-width: none; }

  .card-body { padding: 20px 18px 22px; }
  .rodape { flex-direction: column; }
}

/* Movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    scroll-behavior: auto !important;
  }
  .card:hover, .card:focus-within { transform: none; }
}
