/* ===========================================================================
   Proyectos Open Source Colombianos — hoja de estilos
   Diseño accesible con modo claro y oscuro, contraste AA y foco visible.
   =========================================================================== */

:root {
  color-scheme: light dark;

  --color-bg: #f7f8fa;
  --color-surface: #ffffff;
  --color-surface-2: #eef1f5;
  --color-text: #1a1f29;
  --color-text-muted: #55606f;
  --color-border: #d4dae2;
  --color-primary: #0b5cad;
  --color-primary-contrast: #ffffff;
  --color-accent: #c8102e; /* rojo bandera de Colombia */
  --color-yellow: #fcd116; /* amarillo bandera */
  --color-focus: #0b5cad;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.08);
  --maxw: 1140px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

:root[data-theme="dark"] {
  --color-bg: #0e1420;
  --color-surface: #18202e;
  --color-surface-2: #212b3b;
  --color-text: #eef2f8;
  --color-text-muted: #a4b0c2;
  --color-border: #313d50;
  --color-primary: #5aa9ff;
  --color-primary-contrast: #06101d;
  --color-accent: #ff6b7d;
  --color-focus: #7bbcff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.45);
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 32px);
}

a {
  color: var(--color-primary);
}

/* --- Enlace de salto (skip link) ---------------------------------------- */
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 8px;
}

/* --- Foco visible global ------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Cabecera ------------------------------------------------------------ */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  border-top: 4px solid var(--color-yellow);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding-block: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-flag {
  font-size: 2.2rem;
  line-height: 1;
}

.brand-text h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.7rem);
  line-height: 1.2;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  max-width: 52ch;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* --- Selector de idioma -------------------------------------------------- */
.lang-switch {
  display: inline-flex;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 12px;
  cursor: pointer;
}
.lang-btn:hover {
  color: var(--color-text);
}
.lang-btn[aria-pressed="true"] {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
}

/* --- Botón de tema ------------------------------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text);
  cursor: pointer;
  font-size: 1.2rem;
}
.theme-toggle:hover {
  background: var(--color-border);
}

/* --- Barra de totales / estado ------------------------------------------ */
.site-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.stat-num {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* --- Controles de búsqueda y filtro ------------------------------------- */
.controls {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-block: 28px 8px;
}

@media (max-width: 640px) {
  .controls {
    grid-template-columns: 1fr;
  }
}

.control-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text-muted);
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  pointer-events: none;
  font-size: 1rem;
}

.search-input,
.category-select {
  width: 100%;
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.search-input {
  padding-left: 42px;
}

.category-select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),
    linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) center, calc(100% - 15px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

/* --- Contador de resultados --------------------------------------------- */
.results-count {
  margin: 12px 0 20px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* --- Rejilla de proyectos ------------------------------------------------ */
.project-grid {
  list-style: none;
  margin: 0 0 40px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.project-card:hover,
.project-card:focus-within {
  transform: translateY(-2px);
  border-color: var(--color-primary);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.project-name {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.project-name a {
  color: var(--color-text);
  text-decoration: none;
}
.project-name a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}
/* Hace clicable toda la tarjeta manteniendo accesible el enlace real */
.project-name a::after {
  content: "";
  position: absolute;
  inset: 0;
}
.project-card {
  position: relative;
}

.category-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  white-space: nowrap;
}

.project-desc {
  margin: 0 0 16px;
  color: var(--color-text);
  font-size: 0.95rem;
  flex-grow: 1;
}

.project-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

.meta-label {
  font-weight: 600;
}

/* --- Sin resultados ------------------------------------------------------ */
.no-results {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-muted);
  font-size: 1.05rem;
}

/* --- Pie de página ------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding-block: 28px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.site-footer p {
  margin: 4px 0;
}

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