/* ═══════════════════════════════════════════════════════════
   PLAYAMIGOS — Design System & Styles
   A dark, vibrant, interactive hub for web apps
   ═══════════════════════════════════════════════════════════ */

/* ── Google Fonts (Loaded in parallel inside index.html head) ── */

/* ── Design Tokens ── */
:root {
  color-scheme: dark;

  /* Palette */
  --bg-deep: #050510;
  --bg-primary: #0a0a14;
  --bg-elevated: #111120;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.09);
  --surface-active: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.14);

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: #9090b0;
  --text-muted: #55556e;

  /* Accent */
  --accent-purple: #a855f7;
  --accent-magenta: #ec4899;
  --accent-teal: #06b6d4;

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, #a855f7 0%, #ec4899 50%, #06b6d4 100%);

  /* Typography */
  --font-logo: 'Fascinate', cursive;
  --font-display: 'Quicksand', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

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

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-base: 280ms var(--ease-out);
  --transition-slow: 450ms var(--ease-out);

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 12px 48px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-glow-purple: 0 0 40px rgba(168, 85, 247, 0.2);
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* ═══════════════════════════════════════════
   ANIMATED GRADIENT BACKGROUND
   Vibrant blobs matching teal/magenta/purple ref
   ═══════════════════════════════════════════ */

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg-deep);
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  will-change: transform;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.bg-blob--teal {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(0, 180, 190, 0.45) 0%, transparent 70%);
  top: -10%;
  left: -10%;
  animation: blob-1 12s ease-in-out infinite;
}

.bg-blob--magenta {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(220, 20, 140, 0.5) 0%, transparent 70%);
  bottom: -15%;
  right: -10%;
  animation: blob-2 15s ease-in-out infinite;
}

.bg-blob--purple {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(100, 20, 200, 0.4) 0%, transparent 70%);
  top: 15%;
  left: 20%;
  animation: blob-3 13s ease-in-out infinite;
}

.bg-blob--pink {
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(255, 50, 120, 0.35) 0%, transparent 70%);
  top: 35%;
  right: 5%;
  animation: blob-4 10s ease-in-out infinite;
}

.bg-blob--amber {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.4) 0%, transparent 70%);
  bottom: 25%;
  left: 15%;
  animation: blob-5 11s ease-in-out infinite;
}

@keyframes blob-1 {
  0% {
    transform: translate3d(0, 0, 0) scale(2.2) rotate(0deg);
  }
  33% {
    transform: translate3d(22vw, 15vh, 0) scale(2.6) rotate(120deg);
  }
  66% {
    transform: translate3d(-12vw, 25vh, 0) scale(1.8) rotate(240deg);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(2.2) rotate(360deg);
  }
}

@keyframes blob-2 {
  0% {
    transform: translate3d(0, 0, 0) scale(2.2) rotate(360deg);
  }
  33% {
    transform: translate3d(-24vw, -15vh, 0) scale(1.8) rotate(240deg);
  }
  66% {
    transform: translate3d(15vw, -25vh, 0) scale(2.5) rotate(120deg);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(2.2) rotate(0deg);
  }
}

@keyframes blob-3 {
  0% {
    transform: translate3d(0, 0, 0) scale(2.0) rotate(0deg);
  }
  50% {
    transform: translate3d(18vw, -18vh, 0) scale(2.4) rotate(180deg);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(2.0) rotate(360deg);
  }
}

@keyframes blob-4 {
  0% {
    transform: translate3d(0, 0, 0) scale(1.8) rotate(360deg);
  }
  50% {
    transform: translate3d(-15vw, 18vh, 0) scale(2.2) rotate(180deg);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1.8) rotate(0deg);
  }
}

@keyframes blob-5 {
  0% {
    transform: translate3d(0, 0, 0) scale(2.0) rotate(0deg);
  }
  50% {
    transform: translate3d(-18vw, -12vh, 0) scale(2.3) rotate(180deg);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(2.0) rotate(360deg);
  }
}

/* Noise texture overlay */
.bg-noise {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.3;
  mix-blend-mode: overlay;
}

/* ── Particle Canvas ── */
#particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* ── Page Layout ── */
.page {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100dvh;
  padding: 10dvh var(--space-md) var(--space-sm);
  padding-bottom: 3.5vh;
}

/* ── Hub Hero (Logo + Search Area) ── */
.hub-hero {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding-bottom: var(--space-sm);
}

/* Logo */
.logo {
  font-family: var(--font-logo);
  font-size: clamp(2.0rem, 5.5vw, 3.0rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: #ffffff;
  line-height: 1.1;
  user-select: none;
}

/* Tagline */
.tagline {
  font-family: var(--font-display);
  font-size: clamp(0.78rem, 1.6vw, 0.88rem);
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.04em;
  margin-top: var(--space-2xs);
}

/* ── Search Bar ── */
.search-container {
  width: 100%;
  max-width: 360px;
  margin-top: var(--space-md);
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.4rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  outline: none;
  transition: background var(--transition-base),
              border-color var(--transition-base),
              box-shadow var(--transition-base);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.42);
  font-weight: 400;
}

.search-input:focus {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(168, 85, 247, 0.35);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1),
              0 0 30px rgba(168, 85, 247, 0.08);
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-base);
}

.search-input:focus ~ .search-icon {
  color: var(--accent-purple);
}

/* ── Nav Pills ── */
.nav-pills {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.nav-pill {
  padding: 0.22rem 0.75rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
  letter-spacing: 0.03em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nav-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.nav-pill:active {
  transform: translateY(0);
}

/* ── Category Filters ── */
.filter-section {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  margin-bottom: var(--space-xs);
  padding: 0 var(--space-md);
  z-index: 3;
}

.filter-pill {
  padding: 0.22rem 0.8rem;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
  letter-spacing: 0.02em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.filter-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.filter-pill:active {
  transform: translateY(0);
}

.filter-pill--active {
  color: #ffffff !important;
  background: rgba(168, 85, 247, 0.15) !important;
  border-color: rgba(168, 85, 247, 0.35) !important;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.15);
}

/* ── App Grid Section ── */
.app-section {
  flex: 0 0 auto;
  width: 100%;
  max-height: 48vh;
  overflow-y: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-xs) 0;
}

.app-section::-webkit-scrollbar {
  display: none;
}

.app-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-2xs) var(--space-sm);
}

/* ── App Card ── */
.app-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: var(--space-md);
  width: 250px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-base),
              background var(--transition-base),
              border-color var(--transition-base),
              box-shadow var(--transition-base);
  text-decoration: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  animation: card-enter 0.6s var(--ease-out) both;
}

.app-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.08) 0%, rgba(236, 72, 153, 0.04) 50%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.app-card:hover {
  transform: translateY(-4px) scale(1.015);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-card-hover), var(--shadow-glow-purple);
}

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

.app-card:active {
  transform: translateY(-1px) scale(1.005);
}

.app-card__logo {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 6px;
  margin-bottom: 6px;
  transition: transform var(--transition-base),
              border-color var(--transition-base),
              background var(--transition-base);
}

.app-card:hover .app-card__logo {
  transform: scale(1.08);
  border-color: rgba(168, 85, 247, 0.25);
  background: rgba(255, 255, 255, 0.05);
}

.app-card__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  min-width: 0;
}

.app-card__title {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.app-card__desc {
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.35;
}

.app-card__desc:empty {
  display: none;
}

.app-card__category {
  display: inline-flex;
  align-self: flex-start;
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-teal);
  background: rgba(6, 182, 212, 0.1);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-top: 1px;
}

/* Stagger card entrance animations */
.app-card:nth-child(1) { animation-delay: 0.08s; }
.app-card:nth-child(2) { animation-delay: 0.14s; }
.app-card:nth-child(3) { animation-delay: 0.20s; }
.app-card:nth-child(4) { animation-delay: 0.26s; }
.app-card:nth-child(5) { animation-delay: 0.32s; }
.app-card:nth-child(6) { animation-delay: 0.38s; }

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--text-muted);
  width: 100%;
}

.empty-state__icon {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
  opacity: 0.5;
}

.empty-state__text {
  font-size: 0.9rem;
  font-weight: 400;
}

/* ── Footer ── */
.site-footer {
  position: absolute;
  bottom: var(--space-md);
  left: 0;
  right: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  opacity: 0.6;
}

/* ── About Modal (Native Dialog) ── */
.about-modal {
  background: transparent;
  border: none;
  padding: 0;
  max-width: 500px;
  width: 92%;
  outline: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  overflow: visible;
  z-index: 100;
}

.about-modal::backdrop {
  background: rgba(5, 5, 16, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Chrome/Safari native dialog animation */
.about-modal[open] {
  animation: modal-scale-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.about-modal[open]::backdrop {
  animation: backdrop-fade 0.35s ease-out both;
}

.about-card {
  position: relative;
  width: 100%;
  padding: var(--space-xl);
  background: rgba(15, 15, 30, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 40px rgba(168, 85, 247, 0.1);
  text-align: center;
}

.about-card .logo {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin-bottom: var(--space-xs);
}

.about-card .tagline {
  margin-bottom: var(--space-lg);
}

.about-body {
  text-align: left;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.75;
}

.about-body p + p {
  margin-top: var(--space-md);
}

.about-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-base);
  cursor: pointer;
  z-index: 10;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  transform: scale(1.06);
}

.modal-close svg {
  width: 12px;
  height: 12px;
}

@keyframes backdrop-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-scale-in {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.93);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

/* Mobile & Tablets */
@media (max-width: 768px) {
  .page {
    justify-content: flex-start;
    padding-top: 14dvh; /* generous padding for beautiful negative space and logo safety */
    padding-bottom: 3.5vh;
  }

  .logo {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
  }

  .search-container {
    max-width: 100%;
    margin-top: var(--space-sm);
  }

  .app-grid {
    gap: var(--space-xs);
  }

  .app-card {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
  }

  /* GPU Savings: Hide pink and amber blurs on mobile, reduce blur radius on others */
  .bg-blob--pink,
  .bg-blob--amber {
    display: none;
  }

  .bg-blob {
    filter: blur(60px);
  }

  .about-card {
    padding: var(--space-lg) var(--space-md);
  }
}

/* Small phones */
@media (max-width: 480px) {
  .page {
    padding-top: 14dvh;
    padding-bottom: 3vh;
  }

  .logo {
    font-size: 1.8rem;
  }

  .app-section {
    max-height: 44vh;
  }
}

/* Tablets only */
@media (min-width: 481px) and (max-width: 768px) {
  .app-card {
    width: 250px;
  }
}

/* Large screens */
@media (min-width: 1200px) {
  .app-grid {
    max-width: 1100px;
  }

  .app-card {
    width: 280px;
  }

  .search-container {
    max-width: 400px;
  }
}

/* ═══════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .bg-blob {
    animation: none;
  }

  #particle-canvas {
    display: none;
  }

  .app-card {
    animation: none;
    opacity: 1;
  }

  .app-card:hover {
    transform: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
