/* ═══════════════════════════════════════════════════════════
   IoTFIY — Mobile App Experience (≤767px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  :root {
    --app-header-h: 56px;
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-card-w: min(88vw, 320px);
  }

  /* ── App shell ── */
  body.index-page {
    background: #f1f5f9;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(var(--app-safe-bottom) + 20px);
  }

  body.index-page .main {
    background: #f1f5f9;
  }

  /* Hide desktop-only chrome */
  body.index-page .scroll-progress,
  body.index-page .motion-mesh,
  body.index-page .scroll-top,
  body.index-page .hero-scroll-hint {
    display: none !important;
  }

  /* ── App header ── */
  body.index-page .mobile-navbar {
    display: block !important;
    height: var(--app-header-h);
    padding: 0 16px;
    background: rgba(15, 23, 42, 0.92) !important;
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(99, 102, 241, 0.2) !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  }

  body.index-page .mobile-nav-container {
    height: var(--app-header-h);
  }

  body.index-page .mobile-logo img {
    height: 32px;
    width: auto;
    filter: brightness(0) invert(1);
  }

  body.index-page .mobile-menu-toggle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.25) !important;
    font-size: 1.25rem;
  }

  body.index-page .mobile-menu {
    top: var(--app-header-h);
    background: #0f172a !important;
    border-bottom: none;
  }

  body.index-page .mobile-menu ul li a {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    color: #e2e8f0 !important;
  }

  body.index-page .mobile-menu .menu-group-label {
    color: #818cf8 !important;
  }

  /* Bottom tab bar removed — see index-mobile-premium.css */
  .app-bottom-nav {
    display: none !important;
  }

  /* ── Hero as app splash ── */
  body.index-page .hero-premium {
    min-height: auto !important;
    padding-top: calc(var(--app-header-h) + 1.5rem) !important;
    padding-bottom: 1.5rem !important;
    border-radius: 0 0 28px 28px;
    margin-bottom: 0;
  }

  body.index-page .trust-strip-marquee {
    margin-top: -1px;
  }

  /* Quick nav chips — horizontal */
  .app-quick-nav {
    padding: 1rem 0 0.25rem;
    background: #f1f5f9;
  }

  .app-quick-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 16px 12px;
  }

  .app-quick-scroll::-webkit-scrollbar {
    display: none;
  }

  .app-quick-chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 100px;
    color: #334155;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    white-space: nowrap;
  }

  .app-quick-chip i {
    color: #6366f1;
    font-size: 1rem;
  }

  .app-quick-chip:active,
  .app-quick-chip.active {
    transform: scale(0.96);
    background: #eef2ff;
    border-color: rgba(99, 102, 241, 0.35);
    color: #4338ca;
  }

  /* ── App section blocks ── */
  body.index-page .main > section {
    margin-left: 12px;
    margin-right: 12px;
    border-radius: 24px !important;
    padding-top: 1.75rem !important;
    padding-bottom: 1.75rem !important;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    overflow: hidden;
  }

  body.index-page .main > section.hero-premium {
    margin-left: 0;
    margin-right: 0;
    border-radius: 0 0 28px 28px !important;
    margin-bottom: 0;
    box-shadow: none;
  }

  body.index-page #ai-controller {
    margin-left: 0;
    margin-right: 0;
    border-radius: 0 !important;
  }

  body.index-page .main > section .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Section header — app style with swipe hint */
  .app-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 1.25rem !important;
    text-align: left !important;
  }

  .app-section-head .head-text {
    flex: 1;
    min-width: 0;
  }

  .app-section-head .head-text h2 {
    text-align: left !important;
    margin-bottom: 0.35rem !important;
    font-size: 1.375rem !important;
  }

  .app-section-head .head-text p {
    text-align: left !important;
    margin: 0 !important;
    font-size: 0.875rem !important;
    color: #64748b !important;
    max-width: none !important;
  }

  .app-swipe-hint {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #6366f1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .app-swipe-hint i {
    animation: swipeNudge 1.5s ease-in-out infinite;
  }

  @keyframes swipeNudge {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(4px); }
  }

  .app-see-all {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6366f1;
    text-decoration: none;
    white-space: nowrap;
  }

  /* ── Horizontal card scroller ── */
  .app-h-scroll {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 14px !important;
    margin-left: -16px !important;
    margin-right: -16px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    padding-bottom: 8px !important;
    --bs-gutter-y: 0 !important;
    --bs-gutter-x: 0 !important;
  }

  .app-h-scroll::-webkit-scrollbar {
    display: none;
  }

  .app-h-scroll > [class*="col-"] {
    flex: 0 0 var(--app-card-w) !important;
    max-width: var(--app-card-w) !important;
    width: var(--app-card-w) !important;
    scroll-snap-align: start;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Premium app cards in scrollers */
  .app-h-scroll .service-card,
  .app-h-scroll .product-card,
  .app-h-scroll .value-card,
  .app-h-scroll .tech-item,
  .app-h-scroll .post-card,
  .app-h-scroll .testimonial-card {
    height: 100%;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    background: #fff !important;
    border: 1px solid rgba(99, 102, 241, 0.08) !important;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08) !important;
    border-radius: 20px !important;
    padding: 1.25rem !important;
    text-align: left !important;
  }

  .app-h-scroll .service-card p,
  .app-h-scroll .product-card p,
  .app-h-scroll .portfolio-content p {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.8125rem !important;
    line-height: 1.55 !important;
  }

  .app-h-scroll .service-features,
  .app-h-scroll .product-features,
  .app-h-scroll .portfolio-tech,
  .app-h-scroll .value-features {
    display: none;
  }

  .app-h-scroll .service-icon,
  .app-h-scroll .value-icon {
    width: 52px !important;
    height: 52px !important;
    margin: 0 0 12px 0 !important;
    border-radius: 14px !important;
  }

  .app-h-scroll .service-icon i,
  .app-h-scroll .value-icon i {
    font-size: 1.5rem !important;
  }

  .app-h-scroll .product-image {
    height: 120px !important;
    border-radius: 14px;
    margin-bottom: 12px;
  }

  .app-h-scroll .product-content {
    padding: 0 !important;
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .app-h-scroll .btn-primary-custom {
    margin-top: auto;
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 10px 16px !important;
    font-size: 0.8125rem !important;
    border-radius: 12px !important;
  }

  /* Portfolio horizontal */
  body.index-page #portfolio .portfolio-filters-wrapper {
    display: none !important;
  }

  body.index-page #portfolio .isotope-container.app-h-scroll .portfolio-item {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-self: stretch !important;
    flex: 0 0 min(88vw, 300px) !important;
    max-width: min(88vw, 300px) !important;
    width: min(88vw, 300px) !important;
  }

  body.index-page #portfolio .isotope-container.app-h-scroll {
    align-items: stretch !important;
    height: auto !important;
    min-height: 0 !important;
  }

  body.index-page #portfolio .isotope-container.app-h-scroll .isotope-item {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  body.index-page #portfolio .portfolio-item {
    height: auto;
  }

  body.index-page #portfolio .portfolio-card {
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    padding: 0 !important;
    min-height: 400px;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  body.index-page #portfolio .portfolio-image {
    height: 168px;
    flex-shrink: 0;
    overflow: hidden;
  }

  body.index-page #portfolio .portfolio-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  body.index-page #portfolio .portfolio-content {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  body.index-page #portfolio .portfolio-content h4 {
    font-size: 0.9375rem;
    line-height: 1.35;
    margin-bottom: 0.375rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  body.index-page #portfolio .portfolio-content p {
    font-size: 0.8125rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
  }

  body.index-page #portfolio .portfolio-meta {
    margin-bottom: 0.375rem;
  }

  body.index-page #portfolio .portfolio-tech {
    margin-top: auto;
    flex-wrap: wrap;
    gap: 6px;
  }

  body.index-page #ai-controller .app-h-scroll > [class*="col-"] {
    flex: 0 0 min(92vw, 340px) !important;
    max-width: min(92vw, 340px) !important;
    width: min(92vw, 340px) !important;
  }

  body.index-page #ai-controller .app-h-scroll .ai-control-panel,
  body.index-page #ai-controller .app-h-scroll .computer-vision-display {
    min-height: 360px;
  }

  /* Scroll dots indicator */
  .app-scroll-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 12px 0 4px;
  }

  .app-scroll-dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: width 0.3s, background 0.3s;
  }

  .app-scroll-dots .dot.active {
    width: 20px;
    border-radius: 3px;
    background: #6366f1;
  }

  /* Tech stack horizontal pills */
  .app-h-scroll.app-h-scroll-sm > [class*="col-"] {
    flex: 0 0 140px !important;
    max-width: 140px !important;
    width: 140px !important;
  }

  .app-h-scroll-sm .tech-item {
    min-height: 140px !important;
    padding: 1rem !important;
    text-align: center !important;
  }

  .app-h-scroll-sm .tech-icon {
    width: 44px !important;
    height: 44px !important;
    margin: 0 auto 10px !important;
  }

  .app-h-scroll-sm .tech-item h3 {
    font-size: 0.875rem !important;
  }

  .app-h-scroll-sm .tech-item p {
    font-size: 0.75rem !important;
    margin: 0 !important;
  }

  .app-h-scroll .testimonial-card,
  .app-h-scroll .post-item,
  .app-h-scroll .post-box {
    min-height: 220px;
  }

  .app-h-scroll .post-item {
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  }

  .app-h-scroll .post-img {
    height: 120px;
  }

  .app-h-scroll .post-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .app-h-scroll .post-content {
    padding: 1rem;
  }

  .app-h-scroll .post-title {
    font-size: 0.9375rem !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .app-h-scroll .testimonial-card {
    text-align: left !important;
    min-height: 260px;
  }

  /* About — compact app card */
  body.index-page #about {
    background: #fff !important;
  }

  body.index-page #about .col-lg-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* FAQ accordion app style */
  body.index-page #faq .accordion-button {
    font-size: 0.9375rem;
    padding: 1rem 1.25rem;
    border-radius: 14px !important;
  }

  /* CTA full bleed button */
  body.index-page #cta {
    text-align: center;
    background: linear-gradient(135deg, #6366f1, #7c3aed) !important;
    color: #fff;
  }

  body.index-page #cta h2,
  body.index-page #cta p {
    color: #fff !important;
  }

  /* Footer compact */
  body.index-page .footer {
    margin-bottom: calc(var(--app-safe-bottom) + 12px);
  }

  body.index-page .footer-newsletter {
    padding: 2rem 0;
  }

  /* Chatbot above safe area */
  body.index-page .chatbot-fab {
    bottom: calc(var(--app-safe-bottom) + 16px) !important;
    width: 52px;
    height: 52px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
  }

  body.index-page .chatbot-fab img {
    width: 28px;
    height: 28px;
  }

  body.index-page .chatbot-frame-container {
    bottom: calc(var(--app-safe-bottom) + 12px) !important;
    height: min(70dvh, 520px);
  }

  /* Hide row text-center headers when app-section-head is used */
  .has-app-head .row.text-center.mb-5,
  .has-app-head .container.section-title {
    display: none !important;
  }

  /* AI section compact teaser on mobile */
  body.index-page #ai-controller .row.text-center.mb-5 h2 {
    font-size: 1.5rem !important;
  }

  body.index-page #ai-controller .row.text-center.mb-5 p {
    font-size: 0.875rem !important;
    margin-bottom: 1.5rem !important;
  }

  /* Smooth scroll */
  html {
    scroll-behavior: smooth;
  }
}

/* Desktop — hide app-only elements */
@media (min-width: 768px) {
  .app-bottom-nav,
  .app-quick-nav,
  .app-section-head,
  .app-scroll-dots {
    display: none !important;
  }
}
