/* BX Portal — premium internal navigation */

:root {
  --bg-deep: #06080f;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.18);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #818cf8;
  --accent-glow: rgba(129, 140, 248, 0.35);
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ambient background */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.45;
  animation: float 20s ease-in-out infinite;
}

.orb-1 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, #4f46e5 0%, transparent 70%);
  top: -15%;
  left: -10%;
  animation-delay: 0s;
}

.orb-2 {
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, #0e7490 0%, transparent 70%);
  bottom: -20%;
  right: -5%;
  animation-delay: -7s;
}

.orb-3 {
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  animation-delay: -14s;
  opacity: 0.3;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black 20%, transparent 70%);
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

/* Layout */
.page {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Hero */
.hero {
  text-align: center;
  margin-bottom: 56px;
  animation: fadeUp 0.8s var(--ease) both;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(129, 140, 248, 0.1);
  border: 1px solid rgba(129, 140, 248, 0.25);
  margin-bottom: 20px;
}

.pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  background: linear-gradient(135deg, #fff 0%, #c7d2fe 50%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: clamp(0.7rem, 2.2vw, 1.05rem);
  color: var(--text-muted);
  font-weight: 400;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 16px;
  white-space: nowrap;
}

/* Catalog */
.catalog {
  flex: 1;
}

.section {
  margin-bottom: 48px;
  animation: fadeUp 0.7s var(--ease) both;
}

.section:nth-child(2) { animation-delay: 0.08s; }
.section:nth-child(3) { animation-delay: 0.16s; }
.section:nth-child(4) { animation-delay: 0.24s; }

.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

.section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

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

/* App card */
.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 18px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition:
    transform 0.35s var(--ease),
    background 0.35s var(--ease),
    border-color 0.35s var(--ease),
    box-shadow 0.35s var(--ease);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}

.app-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255,255,255,0.12), transparent 50%, rgba(129,140,248,0.2));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  pointer-events: none;
}

.app-card:hover {
  transform: translateY(-6px);
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: var(--shadow), 0 0 40px -10px var(--accent-glow);
}

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

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

.app-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  flex-shrink: 0;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.app-card:hover .app-icon-wrap {
  transform: scale(1.06);
  box-shadow: 0 8px 24px -8px var(--icon-glow, var(--accent-glow));
}

.app-icon-wrap .app-icon-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.app-icon-wrap .app-icon-letter {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.app-name {
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.01em;
}

.app-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translate(-4px, 4px) scale(0.9);
  transition:
    opacity 0.3s var(--ease),
    transform 0.3s var(--ease),
    color 0.2s,
    background 0.2s,
    border-color 0.2s;
}

.app-card:hover .app-copy,
.app-copy:focus-visible {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.app-copy:hover {
  color: var(--text);
  background: rgba(30, 41, 59, 0.98);
  border-color: rgba(129, 140, 248, 0.45);
}

.app-copy--done {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(6, 78, 59, 0.85);
}

.app-copy svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.app-card--placeholder {
  cursor: default;
}

.app-card--placeholder:hover {
  cursor: pointer;
}

/* Building modal */
body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
}

.modal--visible {
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 15, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.28s var(--ease);
}

.modal--visible .modal-backdrop {
  opacity: 1;
}

.modal-panel {
  position: relative;
  width: min(100%, 400px);
  padding: 36px 32px 28px;
  text-align: center;
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 32px 64px -16px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(129, 140, 248, 0.12) inset,
    0 0 80px -20px rgba(129, 140, 248, 0.25);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition:
    opacity 0.32s var(--ease),
    transform 0.32s var(--ease);
}

.modal--visible .modal-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  transition: color 0.2s, background 0.2s;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

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

.modal-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a5b4fc;
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.2), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(129, 140, 248, 0.3);
  box-shadow: 0 0 40px -8px rgba(129, 140, 248, 0.5);
  animation: modalIconSpin 8s linear infinite;
}

.modal-icon svg {
  width: 36px;
  height: 36px;
}

@keyframes modalIconSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.modal-tag {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 12px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 999px;
}

.modal-title {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #fff 0%, #c7d2fe 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 16px;
}

.modal-app {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  padding: 10px 14px;
  margin-bottom: 24px;
  border-radius: 10px;
  background: rgba(129, 140, 248, 0.08);
  border: 1px solid rgba(129, 140, 248, 0.2);
}

.modal-btn {
  width: 100%;
  padding: 14px 24px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  box-shadow: 0 8px 24px -6px rgba(99, 102, 241, 0.55);
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}

.modal-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px -6px rgba(99, 102, 241, 0.65);
}

.modal-btn:active {
  transform: translateY(0);
}

/* Copy toast */
.copy-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  z-index: 110;
  transform: translateX(-50%) translateY(12px);
  padding: 12px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(129, 140, 248, 0.35);
  box-shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s var(--ease),
    transform 0.3s var(--ease);
}

.copy-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Loading & error */
.loading,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 24px;
  color: var(--text-muted);
}

.loading-ring {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-state {
  color: #fca5a5;
}

.error-state p {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 360px;
  text-align: center;
}

/* Footer */
.footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  animation: fadeUp 0.8s var(--ease) 0.3s both;
}

.footer .dot {
  margin: 0 8px;
  opacity: 0.4;
}

.footer-link {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--accent);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .page {
    padding: 32px 16px 28px;
  }

  .hero {
    margin-bottom: 40px;
  }

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

  .app-card {
    padding: 16px 12px 14px;
  }

  .app-icon-wrap {
    width: 56px;
    height: 56px;
    padding: 6px;
    border-radius: 12px;
  }

  .app-icon-wrap .app-icon-letter {
    font-size: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .modal-icon {
    animation: none;
  }
}
