/*
Theme Name:   DroidPulse
Theme URI:    https://example.com/droidpulse
Author:       Senior WP Architect
Description:  Premium, lightweight Android Apps & Games marketplace theme with Light/Dark mode, AJAX search, modular homepage, and full compatibility with Android App Manager.
Version:      1.1.6
Requires at least: 6.2
Requires PHP: 8.2
Text Domain:  droidpulse
License:      GPLv2 or later
*/

:root {
  --dp-bg: #f8fafc;
  --dp-surface: #ffffff;
  --dp-surface-alt: #f1f5f9;
  --dp-text: #0f172a;
  --dp-text-muted: #475569;
  --dp-border: #e2e8f0;
  --dp-accent: #10b981;
  --dp-accent-hover: #059669;
  --dp-accent-soft: rgba(16, 185, 129, 0.12);
  --dp-radius: 14px;
  --dp-radius-sm: 10px;
  --dp-font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --dp-container: 1240px;
  --dp-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --dp-bg: #0b1120;
  --dp-surface: #111827;
  --dp-surface-alt: #1e293b;
  --dp-text: #f8fafc;
  --dp-text-muted: #94a3b8;
  --dp-border: #1f2937;
  --dp-accent-soft: rgba(16, 185, 129, 0.16);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--dp-font);
  background: var(--dp-bg);
  color: var(--dp-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; }

.dp-container { width: 100%; max-width: var(--dp-container); margin: 0 auto; padding: 0 20px; }

/* Header */
.dp-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--dp-surface);
  border-bottom: 1px solid var(--dp-border);
  backdrop-filter: blur(10px);
}
.dp-header.is-static { position: relative; }
.dp-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; height: 70px; }
.dp-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; }
.dp-logo img { max-height: 40px; width: auto; }
.dp-logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--dp-accent); color: #fff; display: grid; place-items: center; }

.dp-nav { display: flex; align-items: center; gap: 4px; }
.dp-nav a {
  padding: 8px 13px;
  border-radius: var(--dp-radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--dp-text-muted);
  transition: background var(--dp-transition), color var(--dp-transition);
}
.dp-nav a:hover, .dp-nav .current-menu-item > a { background: var(--dp-surface-alt); color: var(--dp-text); }

.dp-header-actions { display: flex; align-items: center; gap: 10px; }
.dp-icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--dp-radius-sm);
  border: 1px solid var(--dp-border);
  background: var(--dp-surface);
  color: var(--dp-text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color var(--dp-transition), background var(--dp-transition);
}
.dp-icon-btn:hover { border-color: var(--dp-accent); background: var(--dp-surface-alt); }
.dp-mobile-toggle { display: none; }

/* Mobile Drawer */
.dp-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(2, 6, 23, 0.55); z-index: 120;
  opacity: 0; pointer-events: none; transition: opacity var(--dp-transition);
}
.dp-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.dp-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 290px; max-width: 85vw;
  background: var(--dp-surface); z-index: 130; padding: 20px;
  transform: translateX(-100%); transition: transform var(--dp-transition);
  display: flex; flex-direction: column; gap: 16px; border-right: 1px solid var(--dp-border);
}
.dp-drawer.is-open { transform: translateX(0); }
.dp-drawer-head { display: flex; align-items: center; justify-content: space-between; }
.dp-drawer-nav { display: flex; flex-direction: column; gap: 6px; }
.dp-drawer-nav a { padding: 11px 14px; border-radius: var(--dp-radius-sm); font-weight: 600; color: var(--dp-text-muted); }
.dp-drawer-nav a:hover { background: var(--dp-surface-alt); color: var(--dp-text); }

/* Search Overlay */
.dp-search-overlay {
  position: fixed; inset: 0; background: rgba(2, 6, 23, 0.65); z-index: 150;
  display: none; align-items: flex-start; justify-content: center; padding: 70px 16px 24px;
}
.dp-search-overlay.is-open { display: flex; }
.dp-search-modal {
  width: 100%; max-width: 680px; background: var(--dp-surface);
  border: 1px solid var(--dp-border); border-radius: var(--dp-radius); overflow: hidden;
}
.dp-search-input-wrap { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--dp-border); }
.dp-search-input-wrap input { flex: 1; border: none; outline: none; background: transparent; color: var(--dp-text); font-size: 1.05rem; }
.dp-search-results { max-height: 420px; overflow-y: auto; padding: 10px; }
.dp-search-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--dp-radius-sm); transition: background var(--dp-transition); }
.dp-search-item:hover { background: var(--dp-surface-alt); }
.dp-search-item img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.dp-search-meta { font-size: 0.82rem; color: var(--dp-text-muted); }

/* Hero */
.dp-hero { padding: 36px 0 20px; }
.dp-hero-box {
  background: var(--dp-surface); border: 1px solid var(--dp-border); border-radius: 20px;
  padding: 32px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: center;
}
.dp-hero h1 { margin: 0 0 10px; font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1.2; letter-spacing: -0.02em; }
.dp-hero p { margin: 0 0 20px; color: var(--dp-text-muted); font-size: 1rem; }
.dp-hero-search {
  display: flex; align-items: center; gap: 8px; background: var(--dp-bg);
  border: 1px solid var(--dp-border); padding: 6px 6px 6px 14px; border-radius: 12px;
}
.dp-hero-search input { flex: 1; border: none; outline: none; background: transparent; color: var(--dp-text); font-size: 0.95rem; }

.dp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--dp-radius-sm); border: none; font-weight: 600; font-size: 0.92rem; cursor: pointer;
  transition: background var(--dp-transition), transform var(--dp-transition);
}
.dp-btn-primary { background: var(--dp-accent); color: #fff; }
.dp-btn-primary:hover { background: var(--dp-accent-hover); transform: translateY(-1px); }
.dp-btn-outline { background: var(--dp-surface); border: 1px solid var(--dp-border); color: var(--dp-text); }
.dp-btn-outline:hover { border-color: var(--dp-accent); }

.dp-featured-stack { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.dp-featured-mini {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--dp-bg); border: 1px solid var(--dp-border); border-radius: var(--dp-radius-sm);
  transition: border-color var(--dp-transition), transform var(--dp-transition);
}
.dp-featured-mini:hover { border-color: var(--dp-accent); transform: translateY(-2px); }
.dp-featured-mini img { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }

/* Sections & App Cards */
.dp-section { padding: 26px 0; }
.dp-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.dp-section-head h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.01em; }
.dp-view-all { font-size: 0.9rem; font-weight: 600; color: var(--dp-accent); }
.dp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.dp-grid-compact { grid-template-columns: repeat(3, 1fr); }

.dp-card {
  background: var(--dp-surface); border: 1px solid var(--dp-border); border-radius: var(--dp-radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color var(--dp-transition), transform var(--dp-transition);
}
.dp-card.is-compact { padding: 12px; gap: 8px; }
.dp-card:hover { border-color: var(--dp-accent); transform: translateY(-2px); }
.dp-card-top { display: flex; align-items: center; gap: 14px; }
.dp-card-icon { width: 60px; height: 60px; border-radius: 14px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--dp-border); }
.dp-card.is-compact .dp-card-icon { width: 48px; height: 48px; border-radius: 11px; }
.dp-card-title { margin: 0 0 4px; font-size: 1rem; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.dp-card-sub { font-size: 0.82rem; color: var(--dp-text-muted); }
.dp-card-meta { display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem; color: var(--dp-text-muted); padding-top: 10px; border-top: 1px solid var(--dp-border); }
.dp-pill { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--dp-accent-soft); color: var(--dp-accent); font-size: 0.75rem; font-weight: 700; }

/* Categories Grid */
.dp-cats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.dp-cat-card {
  background: var(--dp-surface); border: 1px solid var(--dp-border); border-radius: var(--dp-radius-sm);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 0.92rem;
  transition: border-color var(--dp-transition);
}
.dp-cat-card:hover { border-color: var(--dp-accent); color: var(--dp-accent); }
.dp-cat-count { font-size: 0.78rem; color: var(--dp-text-muted); }

/* App Detail Page */
.dp-breadcrumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.86rem; color: var(--dp-text-muted); padding: 18px 0 8px; }
.dp-app-hero {
  background: var(--dp-surface); border: 1px solid var(--dp-border); border-radius: 18px;
  padding: 26px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.dp-app-hero-left { display: flex; align-items: center; gap: 20px; flex: 1; min-width: 260px; }
.dp-app-hero-icon { width: 92px; height: 92px; border-radius: 22px; object-fit: cover; border: 1px solid var(--dp-border); flex-shrink: 0; }
.dp-app-hero h1 { margin: 0 0 6px; font-size: clamp(1.5rem, 2.5vw, 2rem); }
.dp-app-dev { color: var(--dp-accent); font-weight: 600; font-size: 0.95rem; }
.dp-app-stats-bar { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px; font-size: 0.88rem; color: var(--dp-text-muted); }
.dp-app-cta { display: flex; flex-direction: column; gap: 8px; min-width: 230px; }
.dp-btn-download { padding: 14px 24px; font-size: 1rem; border-radius: 12px; }

.dp-detail-layout { display: grid; grid-template-columns: 1fr 330px; gap: 24px; margin-top: 22px; align-items: start; }
.dp-panel { background: var(--dp-surface); border: 1px solid var(--dp-border); border-radius: var(--dp-radius); padding: 22px; margin-bottom: 20px; }
.dp-panel h2 { margin: 0 0 14px; font-size: 1.2rem; }
.dp-panel p { margin: 0 0 12px; }
.dp-panel p:last-child { margin-bottom: 0; }

.dp-gallery-track { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.dp-gallery-item { flex: 0 0 auto; scroll-snap-align: start; border-radius: 10px; overflow: hidden; border: 1px solid var(--dp-border); cursor: zoom-in; }
.dp-gallery-item img { height: 240px; width: auto; object-fit: cover; }

.dp-specs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dp-spec-item { background: var(--dp-bg); border: 1px solid var(--dp-border); border-radius: var(--dp-radius-sm); padding: 10px 14px; }
.dp-spec-label { font-size: 0.78rem; color: var(--dp-text-muted); }
.dp-spec-value { font-weight: 600; font-size: 0.92rem; word-break: break-word; }

.dp-features-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.dp-faq-item { border: 1px solid var(--dp-border); border-radius: var(--dp-radius-sm); margin-bottom: 10px; overflow: hidden; }
.dp-faq-q { width: 100%; text-align: left; background: var(--dp-bg); border: none; padding: 13px 16px; color: var(--dp-text); font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.dp-faq-a { padding: 0 16px 14px; color: var(--dp-text-muted); display: none; font-size: 0.94rem; }
.dp-faq-item.is-open .dp-faq-a { display: block; }

.dp-version-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--dp-border); flex-wrap: wrap; }
.dp-version-row:last-child { border-bottom: none; }
.dp-stars { display: inline-flex; gap: 4px; }
.dp-star-btn { background: none; border: none; font-size: 1.5rem; color: #cbd5e1; cursor: pointer; padding: 0; line-height: 1; }
.dp-star-btn.is-active, .dp-star-btn:hover { color: #f59e0b; }

/* Archive Controls & Pagination */
.dp-archive-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  background: var(--dp-surface); border: 1px solid var(--dp-border); border-radius: var(--dp-radius); padding: 14px 18px; margin-bottom: 20px;
}
.dp-filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.dp-filter-pill { padding: 7px 14px; border-radius: 999px; font-size: 0.86rem; font-weight: 600; border: 1px solid var(--dp-border); color: var(--dp-text-muted); }
.dp-filter-pill.is-active { background: var(--dp-accent); border-color: var(--dp-accent); color: #fff; }
.dp-select { padding: 8px 12px; border-radius: var(--dp-radius-sm); border: 1px solid var(--dp-border); background: var(--dp-bg); color: var(--dp-text); }

.dp-pagination { display: flex; justify-content: center; gap: 8px; margin: 28px 0; flex-wrap: wrap; }
.dp-pagination .page-numbers { padding: 8px 14px; border-radius: var(--dp-radius-sm); border: 1px solid var(--dp-border); background: var(--dp-surface); font-weight: 600; }
.dp-pagination .page-numbers.current { background: var(--dp-accent); border-color: var(--dp-accent); color: #fff; }

/* Modals & Lightbox */
.dp-modal { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.7); z-index: 160; display: none; align-items: center; justify-content: center; padding: 16px; }
.dp-modal.is-open { display: flex; }
.dp-modal-card { width: 100%; max-width: 480px; background: var(--dp-surface); border: 1px solid var(--dp-border); border-radius: var(--dp-radius); padding: 22px; }
.dp-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dp-mirror-list { display: flex; flex-direction: column; gap: 10px; }

.dp-lightbox { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.92); z-index: 180; display: none; align-items: center; justify-content: center; padding: 20px; }
.dp-lightbox.is-open { display: flex; }
.dp-lightbox img { max-height: 88vh; max-width: 92vw; border-radius: 10px; }
.dp-lightbox-close {
  position: absolute; top: 18px; right: 18px; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(15, 23, 42, 0.8);
  color: #fff; font-size: 1.4rem; cursor: pointer; display: grid; place-items: center;
}

.dp-ad-slot { background: var(--dp-surface-alt); border: 1px dashed var(--dp-border); border-radius: var(--dp-radius-sm); padding: 14px; text-align: center; margin: 18px 0; font-size: 0.85rem; color: var(--dp-text-muted); }
.dp-notice { background: var(--dp-surface); border: 1px solid var(--dp-border); border-left: 4px solid var(--dp-accent); border-radius: var(--dp-radius-sm); padding: 18px; margin: 20px 0; }

/* Footer */
.dp-footer { background: var(--dp-surface); border-top: 1px solid var(--dp-border); margin-top: 40px; padding: 40px 0 22px; }
.dp-footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 28px; }
.dp-footer.is-compact .dp-footer-grid { grid-template-columns: 1fr; text-align: center; }
.dp-footer.is-compact .dp-logo { justify-content: center; }
.dp-footer h4 { margin: 0 0 12px; font-size: 0.95rem; }
.dp-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.9rem; color: var(--dp-text-muted); }
.dp-footer ul a:hover { color: var(--dp-accent); }
.dp-footer-bottom { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--dp-border); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; font-size: 0.85rem; color: var(--dp-text-muted); }

@media (max-width: 1024px) {
  .dp-grid { grid-template-columns: repeat(3, 1fr); }
  .dp-cats-grid { grid-template-columns: repeat(3, 1fr); }
  .dp-hero-box, .dp-detail-layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .dp-nav { display: none; }
  .dp-mobile-toggle { display: grid; }
  .dp-grid, .dp-grid-compact { grid-template-columns: repeat(2, 1fr); }
  .dp-footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .dp-grid, .dp-grid-compact, .dp-featured-stack, .dp-cats-grid, .dp-specs-grid, .dp-footer-grid { grid-template-columns: 1fr; }
  .dp-hero-box { padding: 20px; }
  .dp-app-hero { padding: 18px; }
}

/* Mobile-only overflow safeguards. Desktop styling above remains identical to the original theme. */
@media (max-width: 820px) {
  .dp-container { width: 100%; max-width: 100%; padding-left: 16px; padding-right: 16px; }
  .dp-header-inner, .dp-hero-box, .dp-footer-grid { min-width: 0; }
  .dp-logo, .dp-nav, .dp-header-actions, .dp-hero-box > *, .dp-footer-grid > * { min-width: 0; }
  .dp-hero-search { width: 100%; max-width: 100%; min-width: 0; }
  .dp-hero-search input { width: 100%; min-width: 0; }
}
@media (max-width: 540px) {
  .dp-container { padding-left: 14px; padding-right: 14px; }
  .dp-hero-search { display: flex; flex-wrap: nowrap; }
  .dp-hero-search input { flex: 1 1 auto; min-width: 0; }
  .dp-hero-search .dp-btn { flex: 0 0 auto; }
  .dp-app-hero-left, .dp-app-content, .dp-card, .dp-panel { min-width: 0; }
  .dp-footer-grid { grid-template-columns: 1fr 1fr; }
}


/* Mobile header arrangement requested:
   Row 1: logo left, light/dark toggle right.
   Row 2: menu toggle left, search button right.
   Scoped strictly to phones; tablet and desktop remain unchanged. */
@media (max-width: 540px) {
  .dp-header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
    grid-template-rows: 40px 40px;
    grid-template-areas:
      "logo theme"
      "menu search";
    align-items: center;
    column-gap: 10px;
    row-gap: 18px;
    height: auto;
    min-height: 0;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .dp-logo {
    grid-area: logo;
    justify-self: start;
    min-width: 0;
    max-width: 100%;
  }

  .dp-header-actions {
    display: contents;
  }

  #dp-theme-toggle {
    grid-area: theme;
    justify-self: end;
  }

  #dp-open-drawer {
    grid-area: menu;
    justify-self: start;
  }

  #dp-open-search {
    grid-area: search;
    justify-self: end;
  }

  .dp-icon-btn {
    width: 40px;
    height: 40px;
  }

  .dp-logo img {
    max-height: 36px;
    width: auto;
  }

  .dp-logo-mark {
    width: 36px;
    height: 36px;
  }
}


/* Visual divider between the two mobile header rows. */
@media (max-width: 540px) {
  .dp-header-inner {
    position: relative;
  }
  .dp-header-inner::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 59px;
    height: 1px;
    background: var(--dp-border);
    pointer-events: none;
  }
}
