/**
 * SISTEMA DE DISEÑO - José Candon Rubio Portfolio
 * Tokens globales y componentes compartidos
 */

/* ============================================
   TOKENS DE DISEÑO
   ============================================ */

:root {
  /* COLORES */
  --bg: #efd9b4;
  --ink: #151515;
  --ink-soft: #1a1a1a; /* WCAG AA 4.73:1 contra --bg */
  --accent: #6f5d46;
  --accent-light: rgba(111, 93, 70, 0.15);
  --accent-hover: #5a4a38;
  --accent-border: rgba(111, 93, 70, 0.25);
  --border-subtle: rgba(0, 0, 0, 0.1);
  
  /* ESPACIADO */
  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 24px;
  --space-lg: 32px;
  --space-xl: 48px;
  --space-2xl: 64px;
  
  /* TIPOGRAFÍA - Escalas fluidas */
  --text-xs: clamp(13px, 1.7vw, 14px);
  --text-sm: clamp(14px, 1.9vw, 16px);
  --text-base: clamp(16px, 2.1vw, 18px);
  --text-lg: clamp(18px, 2.5vw, 22px);
  --text-xl: clamp(20px, 3vw, 26px);
  --text-2xl: clamp(24px, 3.5vw, 32px);
  --title-sm: clamp(26px, 3.8vw, 40px);
  --title-md: clamp(28px, 4vw, 42px);
  --title-lg: clamp(32px, 5vw, 48px);
  
  /* LINE HEIGHT */
  --lh-tight: 1.2;
  --lh-normal: 1.6;
  --lh-relaxed: 1.7;
  --lh-loose: 1.8;
  
  /* FONT WEIGHTS */
  --fw-normal: 400;
  --fw-medium: 550;
  --fw-semibold: 600;
  --fw-bold: 700;
  
  /* BORDER RADIUS */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* SHADOWS */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.18);
  --shadow-button: 0 4px 14px rgba(111, 93, 70, 0.3);
  --shadow-button-hover: 0 6px 20px rgba(111, 93, 70, 0.4);
  
  /* TRANSITIONS */
  --transition-fast: 0.2s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.3s ease;
  
  /* BREAKPOINTS */
  --breakpoint-sm: 480px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
}

/* ============================================
   RESET Y BASE
   ============================================ */

* {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/var(--lh-normal) -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, system-ui, "Helvetica Neue", sans-serif;
  padding: 40px 20px;
}

@media (max-width: 768px) {
  body {
    padding: var(--space-md) var(--space-sm);
  }
}

/* ============================================
   TIPOGRAFÍA
   ============================================ */

h1 {
  font-size: var(--title-md);
  font-weight: var(--fw-bold);
  margin: 0 0 var(--space-md);
  letter-spacing: 0.3px;
  line-height: var(--lh-tight);
}

h2 {
  font-size: var(--text-2xl);
  font-weight: var(--fw-semibold);
  margin: var(--space-xl) 0 var(--space-sm);
  letter-spacing: 0.2px;
  color: var(--ink);
}

h3 {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  margin: var(--space-lg) 0 var(--space-sm);
  color: var(--accent);
}

p {
  margin: 0 0 var(--space-sm);
  line-height: var(--lh-relaxed);
  color: var(--ink-soft);
}

ul {
  margin: 12px 0;
  padding-left: var(--space-md);
}

li {
  margin-bottom: var(--space-xs);
  color: var(--ink-soft);
}

/* ============================================
   LAYOUT
   ============================================ */

.container {
  max-width: 1000px;
  margin: 0 auto;
}

.section {
  margin-bottom: 40px;
}

/* ============================================
   NAVEGACIÓN
   ============================================ */

/* Header de navegación global */
.site-header {
  max-width: 1000px;
  margin: 0 auto var(--space-xl);
  padding: var(--space-md) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.site-logo {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.3px;
  transition: color var(--transition-base);
}

.site-logo:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: var(--fw-medium);
  font-size: var(--text-sm);
  transition: color var(--transition-base);
  letter-spacing: 0.2px;
}

.nav-link:hover {
  color: var(--ink);
}

.nav-link.active {
  color: var(--accent);
  font-weight: var(--fw-semibold);
}

@media (max-width: 768px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }
  
  .site-nav {
    gap: var(--space-sm);
  }
}

.back-link {
  display: inline-block;
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: var(--fw-medium);
  margin-bottom: var(--space-lg);
  transition: color var(--transition-base);
}

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

.back-link::before {
  content: "← ";
}

/* ============================================
   BOTONES
   ============================================ */

.btn {
  display: inline-block;
  padding: 14px 28px;
  text-decoration: none;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.3px;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  font-size: var(--space-sm);
  border: 2px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-button);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-button-hover);
}

.btn-primary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink-soft);
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: var(--ink);
}

.btn-secondary:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover {
  background: var(--accent);
  color: var(--bg);
}

.btn-outline:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Estilo para botones de acción oscuros */
.cta-primary {
  display: inline-block;
  padding: 16px var(--space-lg);
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: var(--fw-semibold);
  font-size: var(--text-base);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-md);
}

.cta-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.cta-primary:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.cta-primary::after {
  content: " →";
}

/* ============================================
   CARDS Y CONTENEDORES
   ============================================ */

/* Project card para la home */
.project-card {
  background: var(--accent-light);
  border: 2px solid var(--accent-border);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.project-card-image {
  width: 100%;
  height: 80px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--accent-light) 0%, rgba(111, 93, 70, 0.05) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  border-bottom: 1px solid var(--accent-border);
}

.project-card-content {
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1;
}

.project-card-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--ink);
  margin: 0;
  line-height: var(--lh-tight);
}

.project-card-desc {
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin: 0;
  line-height: var(--lh-normal);
  flex: 1;
}

.project-card-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-top: auto;
}

.project-card-tags .tag {
  font-size: 12px;
  padding: 6px 12px;
}

.card {
  background: var(--accent-light);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  border-left: 3px solid var(--accent);
}

.feature-card {
  background: var(--accent-light);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--accent-border);
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.feature-title {
  font-weight: var(--fw-semibold);
  font-size: var(--text-base);
  margin: 0 0 var(--space-xs);
  color: var(--ink);
}

.feature-desc {
  font-size: var(--text-sm);
  margin: 0;
  opacity: 0.8;
  line-height: var(--lh-normal);
  color: var(--ink-soft);
}

.highlight-box {
  background: linear-gradient(135deg, var(--accent-light) 0%, rgba(111, 93, 70, 0.08) 100%);
  border-left: 4px solid var(--accent);
  padding: 24px var(--space-md);
  margin: var(--space-lg) 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: var(--shadow-sm);
}

.highlight-box p:last-child {
  margin-bottom: 0;
}

/* ============================================
   GRIDS
   ============================================ */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
}

/* Grid para project cards */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

/* ============================================
   TAGS Y BADGES
   ============================================ */

.tag {
  display: inline-block;
  padding: var(--space-xs) 14px;
  background: var(--accent-light);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.2px;
  border: 1px solid var(--accent-border);
  transition: all var(--transition-base);
}

.tag:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-1px);
}

.tech-tag {
  padding: var(--space-xs) var(--space-sm);
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.2px;
  border: 1px solid var(--accent-border);
  transition: all var(--transition-base);
}

.tech-tag:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-1px);
}

/* ============================================
   LISTAS CON VIÑETAS PERSONALIZADAS
   ============================================ */

.tech-list {
  list-style: none;
  padding: 0;
  margin: var(--space-sm) 0 0;
}

.tech-list li {
  padding-left: 20px;
  margin-bottom: var(--space-xs);
  position: relative;
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.tech-list li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: var(--fw-semibold);
}

/* ============================================
   LINKS CON EFECTOS
   ============================================ */

.link {
  --boldness: 0;
  position: relative;
  display: inline-block;
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: var(--fw-medium);
  letter-spacing: 0.3px;
  transition: color var(--transition-fast);
  text-shadow:
    calc(var(--boldness) * 0.5px) 0 currentColor,
    calc(var(--boldness) * -0.5px) 0 currentColor,
    0 calc(var(--boldness) * 0.5px) currentColor,
    0 calc(var(--boldness) * -0.5px) currentColor;
}

.link:hover {
  color: var(--ink);
  --boldness: 1.2;
}

.link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  background: currentColor;
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.link:hover::after {
  transform: scaleX(1);
  opacity: 0.75;
}

.link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ============================================
   UTILIDADES
   ============================================ */

.subtitle {
  font-size: var(--text-lg);
  margin-bottom: var(--space-lg);
  color: var(--accent);
  font-weight: var(--fw-medium);
}

.text-center {
  text-align: center;
}

/* Espaciado responsive */
@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-sm);
  }
  
  h1 {
    margin-bottom: var(--space-sm);
  }
}

/* Smooth scroll */
html {
  scroll-behavior: smooth;
}

/* Optimización de imágenes */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

img[loading="lazy"] {
  content-visibility: auto;
}

/* Screenshot image component */
.screenshot-img {
  width: 100%;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  margin: var(--space-lg) 0;
  display: block;
}

/* Reducir movimiento para usuarios con preferencias de accesibilidad */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
