@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=El+Messiri:wght@600;700;800&display=swap');

:root {
  --bg-main: #0b1220;
  --bg-card: #0f172a;
  --bg-soft: #0f172a;
  --border: #1e293b;
  --accent:  #22d3ee;
  --accent2: #0891b2;
  --text:    #e5e7eb;
  --muted:   #94a3b8;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--bg-main);
  color: var(--text);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Layered atmosphere — uses only brand palette */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 80% at 100% 0%, rgba(34, 211, 238, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 90% 60% at 0% 100%, rgba(8, 145, 178, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, var(--bg-main) 0%, #020617 55%, #000 100%);
}

.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: 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)'/%3E%3C/svg%3E");
}

/* Scrollbar — accent matches brand */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-card);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.store-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.store-header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-weight: 900;
  font-size: 22px;
  font-family: 'El Messiri', 'Cairo', sans-serif;
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.35),
    0 8px 28px rgba(0, 0, 0, 0.45);
}

.brand-name {
  font-weight: 800;
  font-size: 19px;
  font-family: 'El Messiri', 'Cairo', sans-serif;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.header-tagline {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(30, 41, 59, 0.8);
  background: rgba(15, 23, 42, 0.5);
}

@media (max-width: 520px) {
  .header-tagline {
    width: 100%;
    text-align: center;
  }
}

.store-main {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px max(14px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  gap: 24px;
}

@media (min-width: 1100px) {
  .store-main {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
    align-items: start;
    gap: 32px;
  }
}

.sidebar {
  display: none;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(30, 41, 59, 0.65);
  border-radius: 20px;
  padding: 18px 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  position: sticky;
  top: 88px;
}

@media (min-width: 1100px) {
  .sidebar {
    display: block;
  }
}

.sidebar-title {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'El Messiri', 'Cairo', sans-serif;
  color: var(--text);
}

.cat-btn {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  text-align: right;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.cat-btn:hover {
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.08);
  color: var(--accent);
}

.cat-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #000;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(34, 211, 238, 0.25);
}

.apps-section {
  min-width: 0;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 4px 1fr;
  gap: 20px;
  align-items: stretch;
  border-radius: 22px;
  padding: 22px 24px;
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  background:
    linear-gradient(145deg, rgba(15, 23, 42, 0.95) 0%, rgba(11, 18, 32, 0.98) 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.hero-accent {
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.35);
}

.hero-copy h1 {
  margin: 0 0 10px;
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  font-weight: 800;
  font-family: 'El Messiri', 'Cairo', sans-serif;
  line-height: 1.25;
}

.hero-copy p {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
  max-width: 52ch;
}

/* Featured */
.featured-slider {
  position: relative;
  width: 100%;
  min-height: 280px;
  border-radius: 22px;
  overflow: hidden;
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.featured-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.65s ease, visibility 0.65s ease;
}

.featured-slide.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.featured-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.35;
  filter: blur(28px) saturate(1.2);
  transform: scale(1.08);
}

.featured-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 280px;
  padding: 28px 28px 40px;
  background: linear-gradient(
    105deg,
    var(--bg-main) 0%,
    rgba(11, 18, 32, 0.97) 45%,
    rgba(11, 18, 32, 0.75) 100%
  );
}

@media (max-width: 640px) {
  .featured-inner {
    flex-direction: column;
    align-items: flex-start;
    text-align: right;
    min-height: 320px;
    padding-bottom: 48px;
  }

  .featured-icon-wrap {
    align-self: center;
  }
}

.featured-content {
  position: relative;
  z-index: 10;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.featured-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: 999px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  width: fit-content;
}

.featured-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  font-family: 'El Messiri', 'Cairo', sans-serif;
  color: #fff;
  margin: 0 0 8px;
  line-height: 1.2;
}

.featured-dl {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.featured-desc {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 20px;
  max-width: 420px;
  line-height: 1.6;
}

.featured-cta.install-btn {
  align-self: flex-start;
}

.featured-icon-wrap {
  flex-shrink: 0;
  padding: 12px;
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.12), rgba(8, 145, 178, 0.08));
  border: 1px solid rgba(34, 211, 238, 0.25);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.featured-icon-img {
  display: block;
  width: clamp(88px, 18vw, 120px);
  height: clamp(88px, 18vw, 120px);
  border-radius: 22px;
  object-fit: cover;
}

.featured-indicators {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 20;
  padding: 0;
  margin: 0;
  list-style: none;
}

.featured-indicator {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.45);
  cursor: pointer;
  transition: width 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.featured-indicator.active {
  width: 28px;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.45);
}

.featured-indicator:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Toolbar: search + pills */
.toolbar {
  margin-bottom: 22px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(30, 41, 59, 0.65);
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
}

.search-container {
  margin-bottom: 16px;
}

.search-wrap {
  display: block;
  position: relative;
  margin: 0;
}

.search-bar {
  width: 100%;
  padding: 14px 18px 14px 48px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-bar::placeholder {
  color: var(--muted);
}

.search-bar:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
}

/* Hide pill row when sidebar is visible — single filter surface */
@media (min-width: 1100px) {
  .toolbar .category-pills {
    display: none;
  }

  .search-container {
    margin-bottom: 0;
  }
}

.category-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  margin: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.category-pills::-webkit-scrollbar {
  height: 4px;
}

.category-pill {
  flex: 0 0 auto;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.75);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.category-pill:hover {
  border-color: rgba(34, 211, 238, 0.4);
  color: var(--text);
  background: rgba(34, 211, 238, 0.08);
}

.category-pill.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #000;
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(34, 211, 238, 0.28);
}

.category-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* App grid */
.apps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 520px) {
  .apps-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 16px;
  }
}

.app-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(30, 41, 59, 0.55);
  border-radius: 20px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.4);
  transition:
    border-color 0.28s ease,
    box-shadow 0.28s ease;
  animation: cardIn 0.55s ease backwards;
  -webkit-tap-highlight-color: transparent;
}

.app-card:nth-child(1) { animation-delay: 0.03s; }
.app-card:nth-child(2) { animation-delay: 0.06s; }
.app-card:nth-child(3) { animation-delay: 0.09s; }
.app-card:nth-child(4) { animation-delay: 0.12s; }
.app-card:nth-child(5) { animation-delay: 0.15s; }
.app-card:nth-child(6) { animation-delay: 0.18s; }
.app-card:nth-child(7) { animation-delay: 0.21s; }
.app-card:nth-child(8) { animation-delay: 0.24s; }
.app-card:nth-child(n+9) { animation-delay: 0.27s; }

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

@media (hover: hover) and (pointer: fine) {
  .app-card:hover {
    transform: translateY(-2px);
    border-color: rgba(34, 211, 238, 0.35);
    box-shadow:
      0 20px 48px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(34, 211, 238, 0.12);
  }

  .app-card:hover .app-icon img {
    box-shadow: 0 12px 32px rgba(34, 211, 238, 0.2);
  }
}

.app-card-body {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 16px 12px;
}

.app-icon {
  flex-shrink: 0;
}

.app-icon img {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  display: block;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.28s ease;
}

.app-info {
  flex: 1;
  min-width: 0;
}

.app-info h2 {
  margin: 0 0 10px;
  font-size: clamp(15px, 3.8vw, 17px);
  font-weight: 700;
  font-family: 'El Messiri', 'Cairo', sans-serif;
  line-height: 1.35;
  word-break: break-word;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.meta-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--muted);
}

.badge {
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.22);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.version,
.size {
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(30, 41, 59, 0.9);
  font-size: 11px;
  line-height: 1.3;
}

.dl-count {
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.28);
  background: rgba(34, 211, 238, 0.08);
  line-height: 1.3;
}

.desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-actions {
  display: flex;
  justify-content: stretch;
  padding: 0 16px 16px;
  margin-top: 0;
  border-top: none;
}

.app-actions .install-btn {
  width: 100%;
  min-height: 46px;
  touch-action: manipulation;
}

.install-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #000;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  font-family: inherit;
  transition: filter 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  box-shadow: 0 4px 18px rgba(34, 211, 238, 0.22);
  touch-action: manipulation;
}

@media (hover: hover) and (pointer: fine) {
  .install-btn:hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 24px rgba(34, 211, 238, 0.4);
    transform: translateY(-1px);
  }
}

.install-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.featured-cta.install-btn {
  width: auto;
  min-height: 44px;
}

.no-apps {
  grid-column: 1 / -1;
  padding: 28px max(16px, env(safe-area-inset-left)) 28px max(16px, env(safe-area-inset-right));
  text-align: center;
  color: #fecaca;
  border-radius: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.35);
}

/* ——— موبايل: تباعد، لمس، شريحة متميزة ——— */
@media (max-width: 639px) {
  .hero {
    padding: 18px 16px;
    border-radius: 18px;
    margin-bottom: 18px;
  }

  .hero-copy p {
    font-size: 14px;
  }

  .featured-slider {
    min-height: auto;
    border-radius: 18px;
  }

  .featured-inner {
    min-height: 0;
    padding: 20px 16px 52px;
    gap: 16px;
  }

  .featured-title {
    font-size: 1.35rem;
  }

  .featured-desc {
    font-size: 14px;
  }

  .featured-cta.install-btn {
    width: 100%;
    justify-content: center;
  }

  .toolbar {
    padding: 14px;
    border-radius: 18px;
  }

  .search-bar {
    font-size: 16px;
    padding: 14px 16px 14px 48px;
  }

  .category-pills {
    gap: 8px;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }

  .category-pill {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 14px;
    scroll-snap-align: start;
    touch-action: manipulation;
  }

  .featured-indicator {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .featured-indicator::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.5);
    transition: width 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
  }

  .featured-indicator.active::after {
    width: 28px;
    background: var(--accent);
    box-shadow: 0 0 14px rgba(34, 211, 238, 0.45);
  }

  .app-card-body {
    padding: 14px 14px 10px;
    gap: 12px;
  }

  .app-icon img {
    width: 64px;
    height: 64px;
    border-radius: 15px;
  }

  .app-actions {
    padding: 0 14px 14px;
  }
}

@media (min-width: 640px) {
  .app-actions {
    justify-content: flex-end;
    padding: 0 16px 16px;
  }

  .app-actions .install-btn {
    width: auto;
    min-width: 132px;
    min-height: 42px;
  }
}
