@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #818cf8;
  --border: rgba(255, 255, 255, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 4rem;
}

/* Authentic Gradient Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% -20%, #312e81 0%, transparent 50%),
    radial-gradient(circle at 0% 100%, #1e1b4b 0%, transparent 40%);
  z-index: -1;
}

header {
  padding: 6rem 1rem 4rem;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

header h1 {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to bottom right, #fff 30%, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
}

header p {
  font-size: 1.25rem;
  color: var(--text-muted);
  font-weight: 300;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  /* More vertical padding for balance */
  text-decoration: none;
  color: inherit;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  height: 100%;
  /* Ensure uniform height if in grid */
}

.app-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.app-card:hover {
  transform: translateY(-5px) scale(1.01);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.app-card:hover::before {
  opacity: 1;
}

.app-tooltip {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0;
  transform: translateY(0);
  transition: all 0.3s ease;
  pointer-events: none;
  border-top: 1px solid var(--border);
  text-align: left;
  /* Keep tooltip text readable */
}

.app-card:hover .app-tooltip {
  opacity: 1;
  transform: translateY(-100%);
}

.app-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
  box-shadow: 0 8px 16px -4px rgba(99, 102, 241, 0.4);
  color: #fff;
  flex-shrink: 0;
}

.app-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0;
  letter-spacing: 0.05em;
  white-space: normal;
  /* Allow slight wrapping if needed, but usually uppercase fits */
  overflow: visible;
  text-overflow: clip;
}

#loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.shimmer {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

/* ==========================================
   Responsive Breakpoints
   ========================================== */

/* Tablet (768px and below) */
@media (max-width: 768px) {
  header {
    padding: 4rem 1rem 3rem;
  }

  header h1 {
    font-size: 2.5rem;
  }

  header p {
    font-size: 1.1rem;
  }

  .container {
    padding: 0 1rem;
  }

  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
  }

  .app-card {
    padding: 1.5rem 1rem;
    border-radius: 16px;
  }

  .app-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .app-name {
    font-size: 0.95rem;
  }

  .app-tooltip {
    font-size: 0.8rem;
    padding: 0.75rem;
  }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
  header {
    padding: 3rem 1rem 2rem;
  }

  header h1 {
    font-size: 2rem;
  }

  header p {
    font-size: 1rem;
  }

  .container {
    padding: 0 0.75rem;
  }

  .app-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .app-card {
    padding: 1.25rem 0.75rem;
    border-radius: 14px;
  }

  .app-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .app-icon svg {
    width: 18px;
    height: 18px;
  }

  .app-name {
    font-size: 0.85rem;
    letter-spacing: 0.03em;
  }

  /* Hide tooltip on mobile - use tap to navigate */
  .app-tooltip {
    display: none;
  }

  /* Disable hover effects on touch devices */
  .app-card:hover {
    transform: none;
  }

  .app-card:active {
    transform: scale(0.98);
    border-color: rgba(99, 102, 241, 0.3);
  }
}

/* Small mobile (360px and below) */
@media (max-width: 360px) {
  header h1 {
    font-size: 1.75rem;
  }

  .app-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .app-card {
    padding: 1rem 0.5rem;
  }

  .app-name {
    font-size: 0.75rem;
  }
}