/* main.css v2 — Artefactos.pro Design System
   Dual theme (dark default + light), accent gold #e8c96a
   Fonts: Instrument Serif, Syne, DM Sans, JetBrains Mono */

/* ========================================
   0. RESET & BASE
   ======================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background .3s ease, color .3s ease;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }

/* ========================================
   1. CSS CUSTOM PROPERTIES — DARK (default)
   ======================================== */
:root,
[data-theme="dark"] {
  --bg:             #0a0a0f;
  --bg-card:        #13131a;
  --bg-card-hover:  #1a1a24;
  --surface:        #1a1a24;
  --text:           #e2e2e2;
  --text-dim:       #9a9ab0;
  --text-muted:     #6b6b80;
  --border:         rgba(255,255,255,0.07);
  --border-hover:   rgba(255,255,255,0.14);

  --accent:         #e8c96a;
  --accent-dim:     rgba(232,201,106,0.12);
  --accent-glow:    rgba(232,201,106,0.25);

  /* Category colors */
  --cat-diversion:     #a78bfa;
  --cat-productividad: #34d399;
  --cat-research:      #60a5fa;
  --cat-creatividad:   #fb923c;
  --cat-educacion:     #fbbf24;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 2px 20px rgba(0,0,0,0.3);
  --shadow-card-hover: 0 8px 40px rgba(0,0,0,0.5);

  color-scheme: dark;
}

/* ========================================
   2. LIGHT THEME
   ======================================== */
[data-theme="light"] {
  --bg:             #f5f3ee;
  --bg-card:        #ffffff;
  --bg-card-hover:  #faf9f6;
  --surface:        #eae8e3;
  --text:           #1a1a2e;
  --text-dim:       #5a5a70;
  --text-muted:     #8a8a9a;
  --border:         rgba(0,0,0,0.08);
  --border-hover:   rgba(0,0,0,0.15);

  --accent:         #c5a03f;
  --accent-dim:     rgba(197,160,63,0.10);
  --accent-glow:    rgba(197,160,63,0.18);

  --cat-diversion:     #7c3aed;
  --cat-productividad: #059669;
  --cat-research:      #2563eb;
  --cat-creatividad:   #ea580c;
  --cat-educacion:     #d97706;

  --shadow-card: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-card-hover: 0 8px 30px rgba(0,0,0,0.1);

  color-scheme: light;
}

/* ========================================
   3. TYPOGRAPHY
   ======================================== */
.font-display { font-family: 'Instrument Serif', Georgia, serif; }
.font-heading { font-family: 'Syne', 'DM Sans', system-ui, sans-serif; }
.font-mono    { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

h1, h2, h3 { font-family: 'Syne', 'DM Sans', system-ui, sans-serif; font-weight: 700; line-height: 1.2; }

/* ========================================
   4. GRAIN OVERLAY
   ======================================== */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}
[data-theme="light"] .grain { opacity: 0.02; }

/* ========================================
   5. PWA INSTALL BANNER
   ======================================== */
#pwa-banner {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: var(--shadow-card-hover);
  max-width: 440px;
  width: calc(100% - 2rem);
}
#pwa-banner[hidden] { display: none; }
#pwa-banner p { font-size: 0.9rem; color: var(--text-dim); flex: 1; }
#pwa-install {
  background: var(--accent);
  color: var(--bg);
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: opacity .2s;
}
#pwa-install:hover { opacity: 0.85; }
#pwa-dismiss {
  font-size: 1.2rem;
  color: var(--text-muted);
  padding: 0.25rem;
  transition: color .2s;
}
#pwa-dismiss:hover { color: var(--text); }

/* ========================================
   6. HEADER
   ======================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(from var(--bg) r g b / 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) var(--space-xl);
}
@supports not (color: rgba(from red r g b / 1)) {
  [data-theme="dark"] .site-header { background: rgba(10,10,15,0.85); }
  [data-theme="light"] .site-header { background: rgba(245,243,238,0.85); }
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.logo {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.5rem;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.logo span { opacity: 0.5; font-weight: 300; }
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
#theme-toggle, #lang-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.1rem;
  transition: background .2s, border-color .2s;
}
#theme-toggle:hover, #lang-toggle:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

/* ========================================
   7. HERO
   ======================================== */
.hero {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl) var(--space-xl);
  max-width: 720px;
  margin: 0 auto;
}
.hero h1 {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  color: var(--accent);
  margin-bottom: var(--space-md);
  line-height: 1.1;
}
.hero p {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--text-dim);
  max-width: 540px;
  margin: 0 auto var(--space-xl);
}

/* Counter badge */
.counter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--accent-dim);
  color: var(--accent);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

/* ========================================
   8. SEARCH
   ======================================== */
.search-wrapper {
  max-width: 480px;
  margin: 0 auto var(--space-lg);
  position: relative;
}
#search-input {
  width: 100%;
  padding: 0.85rem 1.2rem 0.85rem 2.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#search-input::placeholder { color: var(--text-muted); }
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1rem;
}

/* ========================================
   9. FILTERS
   ======================================== */
.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0 var(--space-xl);
  margin-bottom: var(--space-xl);
}
.filter-btn {
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  transition: all .2s;
  white-space: nowrap;
}
.filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--surface);
}
.filter-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
/* Category-colored active states */
.filter-btn[data-filter="diversion"].active     { --accent: var(--cat-diversion); background: rgba(from var(--cat-diversion) r g b / 0.12); border-color: var(--cat-diversion); color: var(--cat-diversion); }
.filter-btn[data-filter="productividad"].active  { --accent: var(--cat-productividad); background: rgba(from var(--cat-productividad) r g b / 0.12); border-color: var(--cat-productividad); color: var(--cat-productividad); }
.filter-btn[data-filter="research"].active       { --accent: var(--cat-research); background: rgba(from var(--cat-research) r g b / 0.12); border-color: var(--cat-research); color: var(--cat-research); }
.filter-btn[data-filter="creatividad"].active    { --accent: var(--cat-creatividad); background: rgba(from var(--cat-creatividad) r g b / 0.12); border-color: var(--cat-creatividad); color: var(--cat-creatividad); }
.filter-btn[data-filter="educacion"].active      { --accent: var(--cat-educacion); background: rgba(from var(--cat-educacion) r g b / 0.12); border-color: var(--cat-educacion); color: var(--cat-educacion); }

/* Fallbacks for browsers without relative color syntax */
@supports not (color: rgba(from red r g b / 1)) {
  .filter-btn[data-filter="diversion"].active     { background: rgba(167,139,250,0.12); border-color: #a78bfa; color: #a78bfa; }
  .filter-btn[data-filter="productividad"].active  { background: rgba(52,211,153,0.12); border-color: #34d399; color: #34d399; }
  .filter-btn[data-filter="research"].active       { background: rgba(96,165,250,0.12); border-color: #60a5fa; color: #60a5fa; }
  .filter-btn[data-filter="creatividad"].active    { background: rgba(251,146,60,0.12); border-color: #fb923c; color: #fb923c; }
  .filter-btn[data-filter="educacion"].active      { background: rgba(251,191,36,0.12); border-color: #fbbf24; color: #fbbf24; }
}

/* ========================================
   10. GRID
   ======================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-xl) var(--space-2xl);
}

/* ========================================
   11. CARD
   ======================================== */
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease, background .25s ease;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}
.card-icon {
  font-size: 2rem;
  margin-bottom: var(--space-xs);
}
.card-name {
  font-family: 'Syne', 'DM Sans', system-ui, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.card-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.5;
  flex: 1;
}
.card-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: fit-content;
}
/* Category-colored top border accent on cards */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: var(--space-lg);
  right: var(--space-lg);
  height: 2px;
  background: var(--card-accent, var(--accent));
  border-radius: 0 0 2px 2px;
  opacity: 0;
  transition: opacity .25s;
}
.card:hover::before { opacity: 1; }

/* Category badge colors */
.card-badge[data-cat="diversion"]     { background: rgba(from var(--cat-diversion) r g b / 0.12); color: var(--cat-diversion); }
.card-badge[data-cat="productividad"] { background: rgba(from var(--cat-productividad) r g b / 0.12); color: var(--cat-productividad); }
.card-badge[data-cat="research"]      { background: rgba(from var(--cat-research) r g b / 0.12); color: var(--cat-research); }
.card-badge[data-cat="creatividad"]   { background: rgba(from var(--cat-creatividad) r g b / 0.12); color: var(--cat-creatividad); }
.card-badge[data-cat="educacion"]     { background: rgba(from var(--cat-educacion) r g b / 0.12); color: var(--cat-educacion); }

@supports not (color: rgba(from red r g b / 1)) {
  .card-badge[data-cat="diversion"]     { background: rgba(167,139,250,0.12); color: #a78bfa; }
  .card-badge[data-cat="productividad"] { background: rgba(52,211,153,0.12); color: #34d399; }
  .card-badge[data-cat="research"]      { background: rgba(96,165,250,0.12); color: #60a5fa; }
  .card-badge[data-cat="creatividad"]   { background: rgba(251,146,60,0.12); color: #fb923c; }
  .card-badge[data-cat="educacion"]     { background: rgba(251,191,36,0.12); color: #fbbf24; }
}

/* "Próximamente" state */
.card.proximamente {
  opacity: 0.55;
  pointer-events: none;
}
.card.proximamente .card-badge {
  background: var(--surface);
  color: var(--text-muted);
}

/* ========================================
   12. EMPTY STATE
   ======================================== */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
  grid-column: 1 / -1;
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}
.empty-state p {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ========================================
   13. FOOTER
   ======================================== */
.site-footer {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}
.site-footer a {
  color: var(--accent);
  transition: opacity .2s;
}
.site-footer a:hover { opacity: 0.75; }
.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
}

/* ========================================
   14. SCROLL REVEAL ANIMATION
   ======================================== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
/* Staggered delay for grid cards */
.card.reveal { transition-delay: calc(var(--i, 0) * 60ms); }

/* ========================================
   15. SKIP LINK (accessibility)
   ======================================== */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--accent);
  color: var(--bg);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 200;
  transition: top .2s;
}
.skip-link:focus { top: var(--space-md); }

/* ========================================
   16. RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .site-header { padding: var(--space-md); }
  .hero { padding: var(--space-xl) var(--space-md) var(--space-lg); }
  .hero h1 { font-size: 2rem; }
  .grid {
    grid-template-columns: 1fr;
    padding: 0 var(--space-md) var(--space-xl);
  }
  .filters {
    padding: 0 var(--space-md);
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filters::-webkit-scrollbar { display: none; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================
   17. REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

/* ========================================
   18. FOCUS VISIBLE
   ======================================== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}
