/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #ffffff;
  --surface:     #f8fafc;
  --border:      #e2e8f0;
  
  /* Cores extraídas do Manual da Marca */
  --brand-primary: #002244;
  --brand-accent:  #0052cc;
  
  --text:        #002244;
  --text-muted:  #64748b;
  --admin-bg:    #f1f5f9;
  --radius:      14px;
  --transition:  0.25s ease;

  /* ── Tamanhos de Imagem ── */
  --img-admin-size:    72px;              
  --img-service-size: calc(var(--img-admin-size) * 2); /* CePIL = 144px */
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Montserrat', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─── */
header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 28px 40px 22px;
  text-align: center;
  position: relative; /* Mantido fixo aqui para controle absoluto dos filhos */
}

header .unicamp-label {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand-accent);
  margin-bottom: 6px;
  font-weight: 700;
}

header .unicamp-label a {
  color: inherit;
  text-decoration: none;
}

header .unicamp-label a:hover {
  text-decoration: underline;
}

header h1 {
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  font-weight: 700;
  color: var(--brand-primary);
  letter-spacing: 0.01em;
}

header p.subtitle {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── Botão Sobre (Header) ─── */
.about-btn {
  position: absolute;
  top: 24px;
  right: 40px;
  background: none;
  border: none;
  color: var(--brand-primary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}

.about-btn svg { width: 24px; height: 24px; }
.about-btn:hover { background: var(--surface); color: var(--brand-accent); }

/* ─── Main layout ─── */
main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 56px 24px 72px;
  width: 100%;
}

/* ─── Section titles ─── */
.section-label {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brand-accent);
  margin-bottom: 10px;
  font-weight: 700;
}

h2.section-title {
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 600;
  color: var(--brand-primary);
  margin-bottom: 32px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ─── Seleção Cruzada (Grayscale Completo) ─── */
.portal:has(.card:hover) .card:not(:hover) {
  filter: grayscale(100%);
  opacity: 0.35;
}

/* ─── Shake Animation ─── */
@keyframes shake {
  0%   { transform: rotate(0deg)  scale(1.02); }
  15%  { transform: rotate(-5deg) scale(1.05); }
  30%  { transform: rotate( 4deg) scale(1.05); }
  45%  { transform: rotate(-3deg) scale(1.04); }
  60%  { transform: rotate( 2deg) scale(1.03); }
  75%  { transform: rotate(-1deg) scale(1.02); }
  100% { transform: rotate(0deg)  scale(1.02); }
}

.card:hover .card-img {
  animation: shake 0.45s ease;
}

/* ─── Shared card base ─── */
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition), filter var(--transition), opacity var(--transition);
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(0, 82, 204, 0.05) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.card:hover::before { opacity: 1; }

.card-img {
  display: block;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: #fff;
  transition: filter var(--transition), transform var(--transition);
  object-fit: contain;
}

.card-name {
  font-weight: 700;
  color: var(--brand-primary);
  text-align: center;
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.card-arrow {
  font-size: 0.75rem;
  color: var(--brand-accent);
  letter-spacing: 0.06em;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--transition), transform var(--transition);
}

.card:hover .card-arrow { opacity: 1; transform: translateY(0); }

/* ─── Service Card (CePIL) ─── */
.service-card {
  background: var(--surface);
  border: 2px solid var(--border);
  padding: 40px 36px 30px;
  width: 290px;
}

.service-card:hover {
  border-color: var(--brand-accent);
  box-shadow: 0 10px 30px rgba(0, 82, 204, 0.1);
}

.service-card .card-img {
  width:  var(--img-service-size);
  height: var(--img-service-size);
  padding: 12px;
  margin-bottom: 24px;
}

.service-card .card-name { font-size: 1.1rem; }
.service-card .card-arrow { margin-top: 20px; }

/* ─── Link principal do card, "esticado" para cobrir o card inteiro ───
   Permite que o card inteiro seja clicável (como antes) mesmo agora que
   "Página do projeto" é um <a> real e independente, sem precisar de JS. */
.card-primary-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  text-decoration: none;
  color: inherit;
}

.card-primary-link::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ─── Link "Página do projeto" (dentro do Service Card) ─── */
.card-project-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  letter-spacing: 0.01em;
  position: relative;
  z-index: 2;
  transition: color var(--transition);
}

.card-project-link:hover,
.card-project-link:focus-visible {
  color: var(--brand-accent);
  outline: none;
}

/* ─── Admin Card (Infraestrutura) ─── */
.admin-card {
  background: var(--admin-bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px 18px;
  width: 190px;
}

.admin-card:hover {
  border-color: var(--brand-primary);
  box-shadow: 0 8px 20px rgba(0, 34, 68, 0.08);
}

.admin-card .card-img {
  width:  var(--img-admin-size);
  height: var(--img-admin-size);
  padding: 7px;
  margin-bottom: 14px;
}

.admin-card .card-name { font-size: 0.85rem; }
.admin-card .card-desc { font-size: 0.75rem; }
.admin-card .card-arrow { margin-top: 14px; }

/* ─── Grids ─── */
.services-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  justify-content: center;
  margin-bottom: 60px;
}

.admin-section { margin-top: 8px; }

/* ─── Redirect banner ─── */
#redirect-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--brand-primary);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 0.85rem;
  color: #ffffff;
  z-index: 100;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

#redirect-banner .timer {
  background: var(--brand-accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

#redirect-banner a {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
}

#redirect-banner a:hover { text-decoration: underline; }

#redirect-banner button {
  background: none;
  border: 1px solid #475569;
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 0.78rem;
  padding: 3px 10px;
  cursor: pointer;
  margin-left: 4px;
}

#redirect-banner button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* ─── Footer ─── */
footer {
  text-align: center;
  padding: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ─── Modal Pop-up Layout ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 34, 68, 0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content {
  background: #ffffff;
  width: 100%;
  max-width: 550px;
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: 0 20px 40px rgba(0, 34, 68, 0.15);
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content { transform: translateY(0); }

.modal-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
  line-height: 1;
}

.modal-close:hover { color: var(--brand-primary); }

/* Estilização Interna Compartilhada do Modal */
.modal-title { font-size: 1.2rem; font-weight: 700; color: var(--brand-primary); margin-bottom: 24px; line-height: 1.4; text-align: left; }
.modal-body { text-align: left; }
.about-section { margin-bottom: 20px; }
.about-section:last-child { margin-bottom: 0; }
.about-section h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brand-accent); margin-bottom: 6px; font-weight: 700; }
.about-section p, .about-section li { font-size: 0.9rem; line-height: 1.6; color: var(--text); }
.about-section ul { list-style-type: none; }
.about-section li { position: relative; padding-left: 16px; }
.about-section li::before { content: "•"; color: var(--brand-accent); position: absolute; left: 0; font-weight: bold; }
.about-section a { color: var(--brand-accent); text-decoration: none; font-weight: 500; }
.about-section a:hover { text-decoration: underline; }
.about-section .coordinator { margin-top: 8px; }

/* ─── Responsivo Geral ─── */
@media (max-width: 768px) {
  :root {
    --img-admin-size:    60px;
    --img-service-size: calc(var(--img-admin-size) * 2); 
  }

  header { padding: 20px 20px 16px; }
  main   { padding: 36px 16px 80px; }

  .about-btn { top: 16px; right: 16px; }
  .modal-content { padding: 28px 24px; }
  .service-card { width: 100%; max-width: 340px; }
  .admin-card   { width: calc(50% - 10px); min-width: 140px; }
}

@media (max-width: 480px) {
  :root {
    --img-admin-size:    52px;
    --img-service-size: calc(var(--img-admin-size) * 2); 
  }

  .service-card { max-width: 300px; }
  .admin-card   { width: 100%; max-width: 280px; }
  .services-grid { gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .card:hover .card-img { animation: none; }
}