/* ============================================
   TRABAJO CIENTÍFICO — Sistema de Certificados
   Superficies planas y rojo oscuro de marca
   ============================================ */

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

:root {
  color-scheme: dark;
  --bg-deep: #0c0d10;
  --bg-surface: #14161b;
  --bg-surface-2: #1b1e25;
  --bg-hover: #232730;
  --border: #262a33;
  --border-hover: #3b414d;
  --text-primary: #f2f3f5;
  --text-secondary: #a9afbc;
  --text-muted: #7d8492;

  /* Rojo oscuro de marca: el 600 actua, el 300 se lee */
  --brand-800: #6b0f18;
  --brand-700: #8c1420;
  --brand-600: #a81b29;
  --brand-500: #c42232;
  --brand-400: #e04352;
  --brand-300: #ff6b78;
  --brand-text: var(--brand-300);
  --brand-tint: rgba(196, 34, 50, 0.12);
  --brand-ring: rgba(196, 34, 50, 0.45);

  /* Alias heredados: el resto de la hoja los usa como color de texto */
  --accent-cyan: var(--brand-text);
  --accent-purple: var(--brand-400);
  --accent-gradient: linear-gradient(135deg, var(--brand-600), var(--brand-800));
  --accent-gradient-h: linear-gradient(90deg, var(--brand-600), var(--brand-800));

  --success: #2fb85f;
  --error: #e0475a;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* --- Animated Background --- */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 15% -5%, rgba(168, 27, 41, 0.22), transparent 70%),
    radial-gradient(700px 420px at 95% 0%, rgba(107, 15, 24, 0.16), transparent 70%);
}

/* Los orbes animados se retiran: el fondo es un lavado
   estático, igual que en el portal. */
.bg-animation .orb { display: none; }

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

/* --- Container --- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* --- Header / Navigation --- */
header {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.brand-badge {
  background: rgba(196, 34, 50, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(196, 34, 50, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
}

.back-link:hover {
  color: var(--accent-cyan);
}

/* --- Main Layout --- */
main {
  flex: 1;
  padding: 3rem 0;
}

.hero-section {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 2.5rem;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.gradient-text {
  color: var(--brand-text);
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1.6;
}

.event-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  padding: 0.5rem 1.25rem;
  border-radius: 30px;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.event-badge span.icon {
  font-size: 1.1rem;
}

/* --- Search Card --- */
.search-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 700px;
  margin: 0 auto 3rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  position: relative;
}

.search-box {
  position: relative;
  display: flex;
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .search-box {
    flex-direction: column;
  }
}

.input-wrapper {
  position: relative;
  flex: 1;
}

.search-input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem 1rem 3rem;
  color: #fff;
  font-size: 1.05rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 4px rgba(196, 34, 50, 0.15);
}

.search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.2rem;
  pointer-events: none;
}

/* --- Autocomplete Dropdown --- */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  display: none;
}

.autocomplete-list.active {
  display: block;
}

.autocomplete-item {
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s;
  font-size: 0.95rem;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover, .autocomplete-item.selected {
  background: var(--bg-hover);
  color: var(--accent-cyan);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.95rem 1.75rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--brand-600);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-500);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(168, 27, 41, 0.35);
}

.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* --- Status Messages --- */
.status-container {
  margin-top: 1.25rem;
}

.status-msg {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-loading {
  background: rgba(196, 34, 50, 0.08);
  border: 1px solid rgba(196, 34, 50, 0.2);
  color: var(--accent-cyan);
}

.status-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.status-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #86efac;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Certificate Section --- */
.certificate-section {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.certificate-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.cert-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
  margin-bottom: 2.5rem;
}

.cert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.cert-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.cert-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Canvas Wrapper */
.canvas-wrapper {
  width: 100%;
  overflow-x: auto;
  background: #000;
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
}

#cert-canvas {
  width: 100%;
  max-width: 1000px;
  height: auto;
  display: block;
  border-radius: 8px;
  aspect-ratio: 1200 / 800;
}

/* --- Information Cards / FAQ --- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 3rem;
}

.info-card {
  background: rgba(19, 22, 39, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.info-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* --- Footer --- */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: auto;
  background: rgba(11, 13, 23, 0.9);
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent-cyan);
}
