/* ─── VARIABLES — misma paleta que el resto del sitio ─────────
   (antes /certifications/ tenía su propio verde y layout de
   feed en lista; ahora hereda los mismos tokens de style.css
   y el patrón de grid de projects/writeups) ────────────────── */
:root {
  --bg:         #0d1117;
  --bg-card:    #161b22;
  --bg-card-2:  #1c2128;
  --bg-card-h:  #21262d;
  --border:     #30363d;
  --border-dim: #21262d;
  --accent:      #f5a524;
  --accent-dim:  #c47e1a;
  --accent-soft: rgba(245, 165, 36, 0.12);
  --text:       #e6edf3;
  --text-dim:   #8b949e;
  --text-muted: #6e7681;
  --mono:       'JetBrains Mono', 'Fira Code', monospace;
  --sans:       'Inter', system-ui, sans-serif;
  --r:          12px;
  --nav-h:      72px;
  --sidebar-w:  260px;
  --right-w:    230px;
}

/* ─── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  overflow-x: hidden;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); }

/* ─── SHELL ──────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--right-w);
  min-height: 100vh;
}

/* ──────────────────────────────────────────────────────────────
   SIDEBAR IZQUIERDA — perfil + búsqueda + filtros (acordeón)
────────────────────────────────────────────────────────────── */
.sidebar-left {
  border-right: 1px solid var(--border-dim);
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}

.profile { display: flex; align-items: center; gap: 0.75rem; }

.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover; flex-shrink: 0;
}

.profile-text { display: flex; flex-direction: column; gap: 0.1rem; overflow: hidden; }

.profile-name {
  font-size: 0.85rem; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.profile-handle { font-size: 0.7rem; color: var(--text-muted); }

.profile-bio {
  font-size: 0.78rem; color: var(--text-dim); line-height: 1.55;
}

/* Búsqueda — en el sidebar */
.search-wrap {
  display: flex; align-items: center; gap: 0.55rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  transition: border-color 0.15s;
}
.search-wrap:focus-within { border-color: var(--accent-dim); }
.search-wrap svg { color: var(--text-muted); flex-shrink: 0; }
.search-wrap input {
  background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--sans); font-size: 0.82rem; width: 100%;
}
.search-wrap input::placeholder { color: var(--text-muted); }

/* ─── FILTROS — ACORDEÓN ──────────────────────────────────────── */
.filters-block { display: flex; flex-direction: column; gap: 0.35rem; }

.filters-title {
  font-family: var(--sans);
  font-size: 0.95rem; font-weight: 700;
  color: var(--text);
  padding-bottom: 0.35rem;
  display: flex; align-items: center; justify-content: space-between;
}

.filters-clear {
  font-family: var(--mono); font-size: 0.65rem;
  color: var(--text-muted); background: none; border: none;
  cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.filters-clear:hover { color: var(--accent); }

.accordion { border-top: 1px solid var(--border-dim); }
.accordion:last-child { border-bottom: 1px solid var(--border-dim); }

.accordion-head {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0.15rem;
  background: none; border: none;
  color: var(--text); font-family: var(--sans); font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
}

.accordion-head .chev {
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.accordion.open .accordion-head .chev { transform: rotate(180deg); color: var(--accent); }

.accordion-body {
  display: none;
  flex-direction: column;
  gap: 0.15rem;
  padding-bottom: 0.65rem;
}
.accordion.open .accordion-body { display: flex; }

.filter-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 0.4rem; border-radius: 7px;
  border: none; background: transparent;
  color: var(--text-dim); font-family: var(--mono); font-size: 0.78rem;
  cursor: pointer; text-align: left; width: 100%;
  transition: background 0.15s, color 0.15s;
}
.filter-btn:hover  { background: var(--bg-card); color: var(--text); }
.filter-btn.active { color: var(--accent); background: var(--accent-soft); }

.filter-num {
  font-size: 0.65rem; color: var(--text-muted);
  background: var(--bg-card-2); border: 1px solid var(--border-dim);
  border-radius: 999px; padding: 0 0.4rem; line-height: 1.6;
  font-family: var(--mono);
}
.filter-btn.active .filter-num { color: var(--accent); border-color: var(--accent-dim); }

/* ──────────────────────────────────────────────────────────────
   FEED / GRID PRINCIPAL
────────────────────────────────────────────────────────────── */
.feed {
  border-right: 1px solid var(--border-dim);
  padding: 1.75rem 2.25rem 3rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}

.feed-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border-dim);
}

.feed-title { font-size: 1.3rem; font-weight: 800; color: var(--text); }

.feed-count {
  font-family: var(--mono); font-size: 0.72rem; color: var(--text-muted);
  flex-shrink: 0;
}

/* ─── GRUPOS Y GRID DE TARJETAS ──────────────────────────────── */
#certs-feed { display: flex; flex-direction: column; gap: 2.5rem; }

.cert-group-label {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 0.7rem; margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--border-dim);
}
.cert-group-count { margin-left: auto; }

.cert-group-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.cert-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  transition: border-color 0.18s, transform 0.18s, background 0.18s;
}
.cert-card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-card-h);
  transform: translateY(-2px);
}

/* Thumb superior (16:9) — insignia centrada, mismo lenguaje que proj-thumb */
.cert-thumb-wrap {
  position: relative;
  aspect-ratio: 16/9;
  background:
    radial-gradient(circle at 30% 20%, var(--accent-soft), transparent 60%),
    repeating-linear-gradient(0deg, var(--border-dim) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, var(--border-dim) 0 1px, transparent 1px 28px),
    var(--bg-card-2);
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
}
.cert-thumb {
  width: 64px; height: 64px;
  object-fit: contain;
  filter: brightness(0.95) saturate(0.9);
  transition: filter 0.2s, transform 0.2s;
  position: relative; z-index: 0;
}
.cert-card:hover .cert-thumb { filter: brightness(1.05) saturate(1.1); transform: scale(1.08); }

.cert-thumb-fallback {
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-dim);
  position: relative; z-index: 0;
}

/* Modo certificado completo: la imagen llena el recuadro 16:9 edge-to-edge
   y el fondo decorativo (grid + gradiente radial) se retira para no competir
   visualmente con el certificado. */
.cert-thumb-wrap.has-cert-image {
  background: var(--bg-card-2);
  overflow: hidden;
  cursor: pointer;
}

.cert-thumb-full {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  z-index: 0;
  filter: brightness(0.95) saturate(0.9);
  transition: filter 0.2s, transform 0.2s;
}
.cert-card:hover .cert-thumb-full { filter: brightness(1.05) saturate(1.05); transform: scale(1.03); }

/* Gradiente oscuro superior para garantizar contraste de las píldoras
   emisor/fecha sin importar el color de fondo del certificado. */
.cert-thumb-gradient {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,14,22,0.65) 0%, rgba(10,14,22,0.18) 38%, rgba(10,14,22,0) 60%);
  pointer-events: none;
  z-index: 0;
}

.cert-issuer-badge {
  position: absolute; top: 0.65rem; left: 0.65rem; z-index: 1;
  display: flex; align-items: center; gap: 0.35rem;
  font-family: var(--mono); font-size: 0.62rem;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  background: rgba(10,14,22,0.75);
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
  color: var(--text-dim);
  max-width: calc(100% - 1.3rem);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.cert-date-badge {
  position: absolute; top: 0.65rem; right: 0.65rem; z-index: 1;
  font-family: var(--mono); font-size: 0.62rem;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  background: rgba(10,14,22,0.75);
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Cuerpo de la tarjeta */
.cert-info { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.1rem 1.15rem 1.15rem; flex: 1; }

.cert-name { font-size: 1rem; font-weight: 700; color: var(--text); line-height: 1.35; }

/* Pie de tarjeta: ver certificado + verificación */
.cert-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--border-dim);
  margin-top: auto;
}

.cert-verify-btn {
  display: flex; align-items: center; gap: 0.45rem;
  font-family: var(--mono); font-size: 0.74rem; font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
}
.cert-verify-btn:hover { background: #ffb648; transform: translateY(-1px); }
.cert-verify-btn svg { flex-shrink: 0; }

/* Botón secundario: abre el certificado en grande (lightbox).
   Estilo "ghost" para no competir con el acento de Verificar. */
.cert-view-btn {
  display: flex; align-items: center; gap: 0.4rem;
  font-family: var(--mono); font-size: 0.74rem; font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.cert-view-btn:hover { border-color: var(--accent-dim); color: var(--text); background: var(--bg-card-2); }
.cert-view-btn svg { flex-shrink: 0; }

.cert-noverify {
  font-family: var(--mono); font-size: 0.72rem; color: var(--text-muted);
}

/* Empty state */
.empty-state {
  padding: 3rem 0; text-align: center;
  font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted);
}

/* ──────────────────────────────────────────────────────────────
   VISOR DE CERTIFICADO — lightbox a pantalla completa
────────────────────────────────────────────────────────────── */
.cert-viewer-overlay {
  position: fixed; inset: 0;
  background: rgba(5,7,10,0.85);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.cert-viewer-overlay.open { opacity: 1; pointer-events: auto; }

.cert-viewer-box {
  position: relative;
  max-width: min(920px, 92vw);
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.75rem;
  display: flex;
}

.cert-viewer-img {
  max-width: 100%;
  max-height: calc(90vh - 1.5rem);
  display: block;
  border-radius: 6px;
  object-fit: contain;
}

.cert-viewer-close {
  position: absolute; top: -14px; right: -14px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  cursor: pointer;
  transition: background 0.15s;
}
.cert-viewer-close:hover { background: #ffb648; }

/* ──────────────────────────────────────────────────────────────
   SIDEBAR DERECHA — total + timeline
────────────────────────────────────────────────────────────── */
.sidebar-right {
  padding: 1.75rem 1.25rem;
  display: flex; flex-direction: column; gap: 1.75rem;
  position: sticky; top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}

.panel-section { display: flex; flex-direction: column; gap: 0.6rem; }

.sidebar-label {
  font-family: var(--mono);
  font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted);
}

.stat-row { display: flex; align-items: baseline; gap: 0.4rem; }
.stat-num { font-size: 1.7rem; color: var(--accent); line-height: 1; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); }

.panel-timeline { flex: 1; min-height: 0; }

.timeline {
  display: flex; flex-direction: column; gap: 0;
  position: relative; overflow-y: auto;
}

.timeline::before {
  content: '';
  position: absolute; left: 6px; top: 4px; bottom: 4px;
  width: 1px; background: var(--border);
}

.tl-item {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.5rem 0; position: relative;
  cursor: pointer; transition: opacity 0.15s;
}
.tl-item:hover { opacity: 0.75; }

.tl-dot {
  width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--bg); margin-top: 3px;
  position: relative; z-index: 1;
  background: var(--accent);
}

.tl-content { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }

.tl-title {
  font-size: 0.78rem; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 150px;
}

.tl-date { font-family: var(--mono); font-size: 0.62rem; color: var(--text-muted); }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .shell { grid-template-columns: var(--sidebar-w) 1fr; }
  .sidebar-right { display: none; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar-left {
    position: static; height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-dim);
  }
  .feed { border-right: none; }
}
@media (max-width: 640px) {
  .feed { padding: 1.25rem 1rem 2rem; }
  .cert-group-items { grid-template-columns: 1fr; }
  .feed-header { flex-wrap: wrap; gap: 0.5rem; }
  .cert-viewer-overlay { padding: 1rem; }
}
