/* Custom Fonts */
@font-face {
  font-family: 'Strayhorn MT';
  src: url('./fonts/strayhorn-mt.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Myriad Pro Condensed';
  src: url('./fonts/Myriad Pro Condensed.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* Root palette */
:root {
  --bg: #0b0b0b;
  --panel: #0f0f10;
  --muted: #9aa0a6;
  --accent: #1db954;
  --card: #121212;
  --glass: rgba(255, 255, 255, 0.04);
  --text-primary: #e8e8e8;
  --text-white: #ffffff;
  --focus-ring: 2px solid var(--accent);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Strayhorn MT', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Accessibility Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--panel);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-shrink: 0;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand .logo {
  border-radius: 8px;
  object-fit: cover;
}

.brand h1 {
  font-size: 1.25rem;
  margin: 0;
  color: var(--text-white);
  font-family: 'Strayhorn MT', sans-serif;
}

.levels {
  flex-shrink: 0;
}

.levels h3 {
  font-size: 1rem;
  margin: 0 0 12px 0;
  color: var(--text-white);
  font-family: 'Strayhorn MT', sans-serif;
}

.levels button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  font-family: 'Strayhorn MT', sans-serif;
}

.levels button:focus-visible,
.categories button:focus-visible,
.resources li:focus-visible,
.search input:focus-visible,
.open-link:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(29, 185, 84, 0.3);
}

.levels button.active,
.levels button:hover {
  background: var(--glass);
  color: var(--text-white);
  transform: translateX(4px);
}

/* Categories Section */
.categories {
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 12px;
  flex-shrink: 0;
}

.categories h3 {
  font-size: 1rem;
  margin: 0 0 12px 0;
  color: var(--text-white);
  font-family: 'Strayhorn MT', sans-serif;
}

.categories button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  font-family: 'Strayhorn MT', sans-serif;
}

.categories button.active,
.categories button:hover {
  background: var(--glass);
  color: var(--text-white);
  transform: translateX(4px);
}

.resources {
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 12px;
  flex-shrink: 0;
}

.resources h3 {
  font-size: 1rem;
  margin: 0 0 8px 0;
  color: var(--text-white);
  font-family: 'Strayhorn MT', sans-serif;
}

.resources ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.resources li {
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s ease;
  font-size: 0.95rem;
  font-family: 'Strayhorn MT', sans-serif;
}

.resources li:hover,
.resources li.active {
  background: var(--glass);
  color: var(--text-white);
  transform: translateX(4px);
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.search {
  width: 100%;
  max-width: 600px;
}

.search input {
  width: 100%;
  padding: 12px 18px;
  border-radius: 24px;
  border: 1px solid transparent;
  background: var(--glass);
  color: var(--text-white);
  font-size: 1rem;
  transition: background 0.2s;
  font-family: 'Strayhorn MT', sans-serif;
}

.search input::placeholder {
  color: var(--muted);
}

.search input:focus {
  background: rgba(255, 255, 255, 0.08);
}

.view-container {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}

/* Cards - Redesigned with large images */
.card {
  background: var(--card);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease;
  overflow: hidden;
  cursor: pointer;
}

.card.motion-in {
  opacity: 1;
  transform: translateY(0);
}

.card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

.card .cover {
  width: 100%;
  height: 280px;
  overflow: hidden;
  flex-shrink: 0;
  background-color: #2a2a2a;
}

.card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card .meta {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card .meta h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-white);
  font-family: 'Strayhorn MT', sans-serif;
}

.card .meta p {
  margin: 0;
  font-size: 10px;
  color: var(--muted);
  font-family: 'Myriad Pro Condensed', sans-serif;
  line-height: 1.4;
}

.card .meta .category-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 4px;
  font-family: 'Myriad Pro Condensed', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.category-badge.historia {
  background: rgba(255, 107, 107, 0.2);
  color: #ff9999;
}

.category-badge.geografia {
  background: rgba(107, 203, 119, 0.2);
  color: #8fd99d;
}

.category-badge.filosofia {
  background: rgba(107, 148, 255, 0.2);
  color: #99b8ff;
}

.category-badge.economia {
  background: rgba(255, 193, 7, 0.2);
  color: #ffd54f;
}

.card .controls {
  margin-top: auto;
  padding-top: 8px;
}

/* Buttons */
.open-link {
  display: inline-flex;
  padding: 8px 16px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-white);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.2s;
  font-family: 'Strayhorn MT', sans-serif;
  width: 100%;
  justify-content: center;
}

.open-link:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Footer */
.footer {
  padding: 16px;
  background: var(--panel);
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  font-family: 'Strayhorn MT', sans-serif;
}

.footer p {
  margin: 0;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Myriad Pro Condensed', sans-serif;
}

.badge.infografia {
  background: rgba(20, 255, 114, 0.2);
  color: #4eff96;
}

.badge.podcast {
  background: rgba(25, 180, 255, 0.2);
  color: #69d2ff;
}

.badge.video {
  background: rgba(255, 77, 77, 0.2);
  color: #ff8585;
}

/* Responsive - Mobile & Tablet */
@media (max-width: 1024px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
  }

  .card .cover {
    height: 240px;
  }
}

@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 16px;
    gap: 16px;
    max-height: none;
    position: relative;
  }

  .brand {
    justify-content: center;
  }

  .levels,
  .categories,
  .resources {
    display: block;
  }

  .topbar {
    padding: 12px;
  }

  .view-container {
    padding: 16px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
  }

  .card .cover {
    height: 200px;
  }

  .card .meta h4 {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .card .cover {
    height: 300px;
  }
}