:root {
  --ifsp-green: #0f8a3b;
  --ifsp-green-dark: #0c6d2f;
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #222;
  --muted: #666;
  --border: #e6e8ec;
  --focus: #1b73e8;
  --footer-height: 120px; /* used to reserve space so footer doesn't overlap content */
}

/* Utility: visually hidden but accessible to screen readers */
.visually-hidden { position: absolute !important; height: 1px; width: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
/* prevent accidental horizontal scroll from wide children (images, maps, long text) */
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }

.topbar {
  position: sticky; top: 0; z-index: 9999;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 45px; height: 45px; object-fit: contain; }
.brand-name { font-weight: 600; color: var(--ifsp-green-dark); }

/* Make brand look like a clickable button when it's an <a> (used on inscrever page) */
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.topbar .brand:hover { opacity: 0.95; }

/* Inscrever page form styling */
.inscrever-form { max-width: 920px; margin: 12px auto 0 auto; padding: 18px; }
.inscrever-form .form-row { display: flex; gap: 14px; margin-bottom: 12px; }
.inscrever-form .form-row .field-label { flex: 1 1 0; display: flex; flex-direction: column; font-weight: 600; color: #222; }
.inscrever-form .field-label .muted { font-weight: 400; color: #6b7280; font-size: 0.95em; margin-left: 6px; }

/* label head: keep title and optional tag on the same line */
.inscrever-form .label-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #222;
}
.inscrever-form .label-head .muted { margin-left: 6px; color: #6b7280; font-weight: 400; font-size: 0.95em; }
.inscrever-form .field-input { margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; background: var(--card); color: var(--text); }
.inscrever-form textarea.field-input { min-height: 140px; resize: none; }
.inscrever-form select.field-input { height: 44px; }

.btn-primary { background: var(--ifsp-green); color: #fff; border: none; padding: 10px 18px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.btn-primary:hover { background: var(--ifsp-green-dark); }

/* Responsive: stack form rows on small screens */
@media (max-width: 760px) {
  .inscrever-form .form-row { flex-direction: column; }
}

.nav a { color: var(--ifsp-green-dark); text-decoration: none; margin-left: 16px; }
.nav a[aria-current="page"] { font-weight: 700; }

.container { max-width: 1100px; margin: 0 auto; padding: 20px; padding-bottom: calc(var(--footer-height) + 20px); }

.hero {
  display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: center; margin-top: 12px;
}
.hero-text h1 { margin: 0 0 8px; }
.meta { color: var(--muted); margin: 6px 0; }

.hero-img { width: 100%; height: 220px; object-fit: cover; border-radius: 12px; background: #ddd; max-width: 100%; }
/* Ensure generic images never overflow their container */
img { max-width: 100%; height: auto; display: block; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-top: 16px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li { margin: 8px 0; }

/* Header for projects list: left column holds title+filters, right column has the search bar */
.list-header { display: flex; align-items: center; gap: 16px; justify-content: space-between; }
.list-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.list-left h1 { margin: 0; line-height: 1.1; white-space: nowrap; }
.filter-box { display: flex; gap: 10px; align-items: center; }
.filter-box select { min-width: 220px; }
.list-right { flex: 1 1 360px; min-width: 0; display: flex; justify-content: flex-end; }
.list-right #buscaProjetos { width: 100%; max-width: 1050px; padding: 12px 14px; font-size: 17px; border-radius: 10px; }

.filtros { align-items: center; margin-top: 6px; }
/* Legacy selector (#busca) and new search input (#buscaProjetos) share styles.
   Increase width so the left side of the projects list looks better. */
#busca, #buscaProjetos {
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 17px; box-sizing: border-box;
  max-width: 100%;     /* keep responsive on small screens */
}

.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 16px;
}
.card-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
}
.card-thumb { width: 100%; height: 140px; object-fit: cover; background: #ddd; }
.card-body { padding: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef7f0; color: var(--ifsp-green-dark); font-size: 12px; margin-right: 6px; }

/* Ensure card title, meta and summary use black color instead of blue */
.card-item h3, .card-item .meta, .card-item p {
  color: #000 !important;
}

/* Links inside cards (title links) should be black and keep the underline on hover if desired */
/* The card itself is an <a> element; ensure it and its states remove underline */
.card-item, .card-item:link, .card-item:visited, .card-item:hover, .card-item:focus {
  color: #000 !important;
  text-decoration: none !important;
}

/* Ensure child text inherits the black color */
.card-item h3, .card-item .meta, .card-item p { color: #000 !important; }

.footer { text-align: center; color: var(--muted); padding: 18px 12px; position: relative; z-index: 1; }
/* Subtle footer link for 'Sobre nós' */
.footer-link-sobre {
  display: block;
  margin: 8px auto 0 auto;
  color: var(--muted);
  font-size: 0.98em;
  text-decoration: underline dotted;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.footer-link-sobre:hover, .footer-link-sobre:focus {
  opacity: 1;
  color: var(--muted);
  text-decoration: underline;
}

/* Custom footer layout similar to provided design */
.footer {
  background: #3d1850; /* deep purple similar to image */
  color: #f3e9f3;
  padding: 28px 16px;
  text-align: left;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between; /* spread left / center / right for balanced layout */
  gap: 16px;
}

/* Three-column footer: left / center / right */
.footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto; /* don't force big widths */
  justify-content: flex-start;
  flex-wrap: wrap; /* allow wrapping when needed */
}
.footer-center {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px; /* nudge closer to text on the right */
}
.footer-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}
.footer .footer-link-sobre,
.footer .footer-link-inscrever {
  display: inline-block;
  margin: 0 12px 0 0; /* reduced space between links for compact layout */
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  opacity: 0.95;
  font-size: 0.98em;
  vertical-align: middle;
  white-space: nowrap;
}
.footer .footer-link-sobre:last-of-type, .footer .footer-link-inscrever:last-of-type { margin-right: 0; }
.footer .footer-link-sobre:hover, .footer .footer-link-inscrever:hover { text-decoration: underline; opacity: 1; }
.cc-link { display: inline-flex; align-items: center; color: #fff; text-decoration: none; }
.cc-icon { color: #fff; opacity: 0.95; margin-right: 8px; }
.cc-text { font-size: 0.95rem; line-height: 1.2; color: #f3e9f3; margin-left: 6px; }

/* Desktop: nudge CC container slightly to the right and tighten icon-text spacing */
@media (min-width: 900px) {
  .cc-link { margin-left: 8px; }
  .cc-icon { margin-right: 6px; }
  .cc-text { margin-left: 4px; }
}

/* Creative Commons logo sizing - reduced so it's not overly prominent */
.cc-link img, .cc-icon {
  width: 56px !important;
  height: 32px !important;
  margin-right: 12px !important;
  border-radius: 6px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.12);
  object-fit: contain;
}

@media (max-width: 600px) {
  .cc-link img, .cc-icon {
    width: 56px !important;
    height: 32px !important;
    margin-right: 12px !important;
  }
}

@media (max-width: 700px) {
  .footer-inner { flex-direction: column; align-items: center; }
  .footer-right { margin-top: 8px; }
  .cc-text { font-size: 0.92rem; }
}

/* Better mobile footer: center content, allow wrapping and comfortable spacing */
@media (max-width: 600px) {
  .footer {
    padding: 20px 12px;
    text-align: center; /* make overall footer centered */
  }
  .footer-inner {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
  }
  .footer-left, .footer-center, .footer-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 6px 0;
  }
  .footer-left { flex-wrap: wrap; gap: 8px; }
  .footer .footer-link-sobre, .footer .footer-link-inscrever {
    margin: 4px 8px; /* reduced margins for mobile */
    white-space: normal; /* allow wrapping */
    font-size: 0.95em;
  }
  .cc-link img, .cc-icon {
    width: 56px !important;
    height: 32px !important;
    margin-right: 8px !important;
  }
  .cc-text { font-size: 0.88rem; text-align: center; }
  .footer-right { justify-content: center; }
}

.mapa-box { height: 260px; background: #e9f3ec; border: 1px dashed var(--ifsp-green); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--ifsp-green-dark); }

/* Responsivo */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
/* Scroll-to-top button (circular, responsive, footer-aware) */
.scroll-top {
  --scroll-top-bottom: 28px;
  --scroll-top-offset: 0px;
  position: fixed;
  right: 28px;
  bottom: calc(var(--scroll-top-bottom) + var(--scroll-top-offset));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0b6efd; /* primary */
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(11,110,253,0.18);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease, visibility 200ms;
  z-index: 20000; /* make sure it's above most page layers including footer */
  appearance: none; border: none; padding: 0; background-clip: padding-box;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  pointer-events: auto;
}
.scroll-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.scroll-top.shift-up {
  /* when shifted up due to footer overlap, slightly increase elevation so it remains visible */
  box-shadow: 0 10px 20px rgba(11,110,253,0.18);
}
.scroll-top:focus { outline: 3px solid rgba(11,110,253,0.25); }
.scroll-top svg { width: 20px; height: 20px; }
.scroll-top svg path { fill: #fff !important; }

@media (min-width: 900px) {
  .scroll-top { width:56px; height:56px; right:34px; --scroll-top-bottom: 34px; }
  .scroll-top svg { width:22px; height:22px; }
}
@media (max-width: 640px) {
  .scroll-top { right: 16px; --scroll-top-bottom: 16px; width:44px; height:44px; }
}
@media (prefers-reduced-motion: no-preference) {
  .scroll-top.show { animation: scrollTopPop 240ms ease; }
  @keyframes scrollTopPop {
    from { transform: translateY(8px) scale(.96); opacity: 0 }
    to   { transform: translateY(0) scale(1); opacity: 1 }
  }
}
:focus { outline: 3px solid var(--focus); outline-offset: 2px; }

/* 🔎 Barra de busca */
#busca {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
#busca:focus {
  border-color: var(--ifsp-green);
  box-shadow: 0 0 0 3px rgba(15, 138, 59, 0.2);
  outline: none;
}

/* 🎛️ Filtros */
.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}
.filtros select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* ensure uniform select sizing and responsive shrink */
.filter-box select { flex: 0 0 195px; min-width: 140px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); }

@media (max-width: 600px) {
  .list-header { flex-direction: column; align-items: stretch; }
  .list-left { width: 100%; justify-content: space-between; }
  .filter-box { margin-top: 8px; flex-wrap: wrap; }
  .list-right { width: 100%; margin-top: 10px; }
}
/* Mobile-only adjustments: make the two selects and the search input stack
   vertically and fill the available width, matching size/style. */
@media (max-width: 600px) {
  .list-header { align-items: stretch; }
  .filter-box, .filtros {
    display: flex;
    flex-direction: column;
    gap: 14px; /* increased gap for better spacing between filters */
    align-items: stretch;
    margin: 8px 0;
  }

  /* Make selects full-width and visually match the search input */
  .filter-box select,
  .filtros select,
  .filter-box select:focus,
  .filtros select:focus {
    flex: none;
    width: 100%;
    min-width: 0;
    height: 48px; /* explicit vertical size to match the search input */
    padding: 0 14px; /* use horizontal padding; height controls vertical size */
    font-size: 16px;
    line-height: 1.2;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
  }

  /* Ensure the search input also fills the width and matches styling */
  #buscaProjetos,
  #busca {
    width: 100% !important;
    max-width: 100% !important;
    height: 48px; /* match selects */
    padding: 0 14px; /* horizontal padding only, vertical size controlled by height */
    font-size: 16px;
    line-height: 1.2;
    border-radius: 10px;
    box-sizing: border-box;
  }

  /* Make sure the right-side container does not keep elements floated to the right */
  .list-right { justify-content: flex-start; }

  /* Remove any reserved vertical space left by previous layout: ensure
     header and filter containers don't keep an explicit min-height, padding
     or margins that create an empty gap between the search and the list. */
  .list-header, .list-left, .list-right, .filter-box, .filtros {
    min-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    align-items: flex-start !important;
  }

  /* Ensure the selects are visible and not overflowing/hidden; they must
     occupy only their natural height so no blank area is reserved. */
  .filter-box select, .filtros select { display: block; visibility: visible; }

  /* Prevent the search input from creating extra vertical space via box-sizing */
  #buscaProjetos, #busca { box-sizing: border-box; display: block; }

  /* As a safety measure, collapse any empty text nodes or line-height issues */
  .list-header * { line-height: normal; }

  /* Aggressive collapse: ensure no fixed heights remain and force standard
     document flow (stacking) so content below follows immediately. */
  .list-header, .list-left, .list-right { display: block !important; height: auto !important; }
  .filter-box { display: flex !important; flex-direction: column !important; gap: 14px !important; }
  .list-left { margin-bottom: 0 !important; }
  /* add spacing between the filter column and the search input on mobile */
  .list-right { margin-top: 14px !important; }

  /* make the counter sit immediately below the header */
  /* Force no gap between search and contador */
  #buscaProjetos, #busca { margin-bottom: 4px !important; }
  .contador { margin-top: 0 !important; margin-bottom: 6px !important; }

  /* Ensure the card wrapper doesn't add top margin on mobile */
  .card { margin-top: 8px !important; }
}
.filtros select:focus {
  border-color: var(--ifsp-green);
  box-shadow: 0 0 0 3px rgba(15, 138, 59, 0.2);
  outline: none;
}

/* Toast notification for filter application (over map top-right) */
.filter-toast {
  position: absolute; /* by default we attach inside the #map */
  right: 12px;
  top: 12px;
  background: rgba(34,34,34,0.92);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 9999;
  pointer-events: none;
}
.filter-toast.fixed {
  position: fixed; right: 22px; top: 92px; z-index: 99999;
}
.filter-toast.show { opacity: 1; transform: translateY(0) scale(1); }

/* 📊 Contador de resultados */
.contador {
  margin: 12px 0;
  font-weight: 600;
  color: var(--ifsp-green-dark);
}

/* 📩 Seção de Feedback */
.card h2 {
  margin-bottom: 10px;
  color: var(--ifsp-green-dark);
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.feedback-form textarea {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  /* Make textarea fixed-size and non-resizable */
  resize: none !important;
  height: 120px !important; /* fixed height */
  width: 100% !important; /* full width of container */
  overflow: auto !important;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.feedback-form textarea:focus {
  border-color: var(--ifsp-green);
  box-shadow: 0 0 0 3px rgba(15, 138, 59, 0.2);
  outline: none;
}

.feedback-form button {
  align-self: flex-start;
  background: var(--ifsp-green);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}

.feedback-form button:hover {
  background: var(--ifsp-green-dark);
  transform: translateY(-1px);
}

.feedback-form button:active {
  transform: translateY(0);
}

/* ✅ Mensagem de retorno do Feedback */
.feedback-msg {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.feedback-msg.show {
  opacity: 1;
  transform: translateY(0);
}

.feedback-msg.success {
  background: #e6f9ed;
  color: var(--ifsp-green-dark);
  border: 1px solid var(--ifsp-green);
}

.feedback-msg.error {
  background: #fdecea;
  color: #d93025;
  border: 1px solid #d93025;
}

