/* ==========================================================================
   ApnaLead — Responsive System
   --------------------------------------------------------------------------
   Mobile is not a compressed desktop. Several components change layout model
   entirely below 820px — notably the ecosystem flow (horizontal → vertical
   timeline), the process steps and the stats grid.

   Breakpoints: 1280 · 1140 · 1024 · 900 · 820 · 640 · 480 · 380
   ========================================================================== */

/* ---------- 1280px : large laptop ---------------------------------------- */
@media (max-width: 1280px) {
  .eco__note { display: none; }
  .linkgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 1140px : nav crowding ---------------------------------------- */
@media (max-width: 1140px) {
  .nav__link { padding: .55rem .62rem; font-size: .862rem; }
  .nav__actions { margin-left: .5rem; }
}

/* ---------- 1024px : tablet landscape ------------------------------------ */
@media (max-width: 1024px) {
  :root { --header-h: 78px; }

  /* Navigation collapses to the drawer */
  .nav { display: none; }
  .nav__actions { display: none; }
  .nav-toggle { display: flex; }

  .hero__grid { grid-template-columns: 1fr; gap: clamp(2.5rem, 2rem + 3vw, 3.5rem); }
  .hviz { max-width: 620px; margin-inline: auto; width: 100%; }
  /* Stacked layout leaves no clear space above the stage — keep the lower chip only. */
  .hviz__chip--tl { display: none; }

  .page-hero__grid { grid-template-columns: 1fr; gap: 2rem; align-items: start; }

  .split { grid-template-columns: 1fr; gap: 2.5rem; }
  .split--reverse .split__visual { order: 0; }

  .prod { grid-template-columns: 1fr; gap: 2.25rem; }
  .prod--flip .prod__visual { order: 0; }

  .cta__inner { grid-template-columns: 1fr; }

  .sec-head--split { grid-template-columns: 1fr; gap: 1.25rem; align-items: start; }
  .sec-head--split .sec-head__aside { padding-bottom: 0; }

  .article-layout { grid-template-columns: 1fr; }
  .article-aside { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .footer__top { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .footer__brand { grid-column: 1 / -1; }

  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .speclist > div { grid-template-columns: 160px minmax(0, 1fr); gap: 1rem; }
}

/* ---------- 900px : mid tablet ------------------------------------------- */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Process becomes a vertical rail — numbers stay large and editorial */
  .steps { grid-template-columns: 1fr; border-top: 0; }
  .step {
    border-right: 0;
    border-left: 2px solid var(--line);
    padding: 1.75rem 0 1.75rem 1.5rem !important;
  }
  .step::before { display: none; }
  .step__no { margin-bottom: .75rem; -webkit-text-stroke-width: 1.2px; }

  .prod__features { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .ind-card--feature { grid-column: 1 / -1; }
}

/* ---------- 820px : ecosystem switches orientation ----------------------- */
@media (max-width: 820px) {
  /* Horizontal flow → vertical timeline. Deliberate mobile layout. */
  .eco {
    grid-template-columns: 1fr;
    gap: 0;
    padding-left: 6px;
  }
  .eco::before {
    left: 34px; right: auto;
    top: 34px; bottom: 34px;
    width: 2px; height: auto;
    background: linear-gradient(180deg,
      rgba(62, 134, 212, .06) 0%,
      rgba(62, 134, 212, .45) 12%,
      rgba(74, 77, 232, .5) 50%,
      rgba(110, 231, 168, .45) 88%,
      rgba(110, 231, 168, .06) 100%);
  }
  .eco::after {
    left: 30px;
    top: 34px;
    animation: eco-travel-v 6s linear infinite;
  }
  @keyframes eco-travel-v {
    0%   { top: 34px; opacity: 0; }
    6%   { opacity: 1; }
    94%  { opacity: 1; }
    100% { top: calc(100% - 44px); opacity: 0; }
  }
  .eco__node {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 1rem;
    padding-block: .7rem;
  }
  .eco__dot { width: 52px; height: 52px; flex: none; }
  .eco__note { display: block; }
  .eco__node > div { display: grid; gap: .1rem; }

  .tst__msg { font-size: .975rem; }
  .faq__a p { padding-right: 2.5rem; }
}

/* ---------- 780px : modal stacks ----------------------------------------- */
@media (max-width: 780px) {
  /* Side-by-side no longer fits. The dark panel becomes a compact header so
     the form itself stays above the fold on a phone. */
  .modal { place-items: start center; padding: 0; }
  .modal__dialog {
    grid-template-columns: 1fr;
    border-radius: 0;
    min-height: 100%;
  }
  .modal__aside { padding: 1.5rem 1.25rem 1.35rem; }
  /* Now over the dark aside — invert it back. */
  .modal__close {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .26);
    color: #fff;
  }
  .modal__close:hover { background: rgba(255, 255, 255, .28); border-color: rgba(255, 255, 255, .4); }
  .modal__points,
  .modal__alt { display: none; }
  .modal__text { margin-bottom: 0; }
  .modal__body { padding: 1.35rem 1.25rem 2rem; }
}

/* ---------- 640px : phone landscape / small tablet ----------------------- */
@media (max-width: 640px) {
  :root {
    --header-h: 72px;
    --section-y: clamp(3.25rem, 2.5rem + 3vw, 4.5rem);
  }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Stats: 4 across → 2×2 with visible cell borders */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 1.35rem 1.1rem; }
  .stat__val { font-size: 1.85rem; }

  .hero { padding-top: calc(var(--header-h) + 2.25rem); }

  /* The badge is a pill-inside-a-pill. Once it wraps, a pill radius reads as a
     rendering fault — so it becomes a soft-cornered block instead. */
  .hero__badge {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    row-gap: .4rem;
    border-radius: var(--r-md);
    padding: .55rem .75rem;
    font-size: .78rem;
    line-height: 1.35;
  }
  .hero__badge b { font-size: .62rem; }
  .hero__cta { gap: .6rem; }
  .hero__cta .btn { flex: 1 1 100%; }
  .hero__proof { gap: 1.15rem 1.75rem; }
  .hero__proof-val { font-size: 1.24rem; }

  /* Hero visual: trim the dashboard to what reads well on a phone */
  .hviz__glow { display: none; }
  .hviz__chip--tl,
  .hviz__chip--br { display: none; }
  .dash__metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
  .metric { padding: .5rem .55rem; }
  .metric__val { font-size: 1rem; }
  .metric__lbl { font-size: .56rem; letter-spacing: .06em; }
  .dash__chart { height: 74px; }
  .feed__row:nth-child(n + 4) { display: none; }
  .pipe { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: .7rem .5rem; }
  .pipe__val { font-size: .92rem; }
  .pipe__lbl { font-size: .54rem; letter-spacing: .05em; }
  .chan { padding: .55rem .6rem; }
  .chan__val { font-size: .9rem; }
  .chan__name { font-size: .6rem; }
  /* "+18% vs last month" wraps to two lines in a 100px column and leaves the
     three channel cards different heights. Keep the delta, drop the comparison. */
  .chan__delta .chan__vs { display: none; }

  .prod__features { grid-template-columns: 1fr; gap: .5rem; }
  .prod { padding-block: 2.25rem; }

  .cta-inline { flex-direction: column; align-items: flex-start; }
  .cta__actions .btn,
  .cta-inline .btn { width: 100%; }

  .form__grid { grid-template-columns: 1fr; }

  .article-aside { grid-template-columns: 1fr; }

  .footer__top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer__bottom { flex-direction: column; align-items: flex-start; gap: .8rem; }
  .footer__legal { gap: .9rem; }

  .linkgrid { grid-template-columns: 1fr; }

  .speclist > div { grid-template-columns: 1fr; gap: .3rem; padding: .9rem 0; }

  .filters { gap: .4rem; overflow-x: auto; flex-wrap: nowrap; padding-bottom: .5rem; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); }
  .filters::-webkit-scrollbar { display: none; }
  .filters { scrollbar-width: none; }
  .filter { flex: none; }

  /* Floating actions shrink to icons so they never cover content */
  .fab { height: 50px; width: 50px; padding: 0; justify-content: center; }
  .fab span { display: none; }
  .to-top { width: 40px; height: 40px; }

  .prose { font-size: 1.02rem; }
  .prose blockquote { padding: 1rem 1.15rem; }

  .case-card__no { font-size: 2.4rem; }
  .promise li { grid-template-columns: 1fr; gap: .25rem; }
}

/* ---------- 480px : standard phone --------------------------------------- */
@media (max-width: 480px) {
  :root { --gutter: 1.15rem; }

  .brand img { height: 38px; }
  .header.is-scrolled .brand img { height: 32px; }

  .hero__proof { gap: 1rem 1.5rem; }
  .hero__proof-item { min-width: calc(50% - .75rem); }

  /* Single column: the number sits beside a stacked label + note rather than
     all three fighting for one baseline row. */
  .stats { grid-template-columns: 1fr; }
  .stat {
    display: grid;
    grid-template-columns: minmax(0, 6.75rem) minmax(0, 1fr);
    column-gap: .9rem;
    align-items: center;
    padding: 1.05rem .25rem;
  }
  .stat__val {
    grid-column: 1;
    grid-row: 1 / span 2;
    /* Values are configurable, so a long word like "Multiple" must shrink and
       wrap inside the column rather than run into the label beside it. */
    font-size: clamp(1.2rem, 5.4vw, 1.7rem);
    overflow-wrap: anywhere;
    hyphens: auto;
    margin-bottom: 0;
  }
  .stat__lbl  { grid-column: 2; grid-row: 1; }
  .stat__note { grid-column: 2; grid-row: 2; }

  .trust__caps { gap: .4rem; }
  .cap { padding: .45rem .8rem; font-size: var(--fs-xs); }

  .faq__q { font-size: .98rem; gap: 1rem; padding: 1.15rem 0; }
  .faq__a p { padding-right: 1.5rem; }

  .form-panel { padding: 1.25rem; border-radius: var(--r-md); }
  .contact-row { padding: .85rem .95rem; }

  .mock__body { padding: .7rem; }
  .mock-kpis { gap: .35rem; }
  .mock-kpi { padding: .45rem .5rem; }
  .mock-kpi b { font-size: .88rem; }
  .mock-kpi span { font-size: .52rem; }
  .mock-bar { grid-template-columns: 60px minmax(0, 1fr) 30px; }

  .eco__dot { width: 46px; height: 46px; }
  .eco__dot .icon { width: 20px; height: 20px; }
  .eco::before { left: 29px; }
  .eco::after { left: 25px; }

  .statement { padding: 1.5rem 1.25rem; border-radius: var(--r-lg); }
  .ind-card, .card, .case-card, .tst { border-radius: var(--r-md); }
}

/* ---------- 380px : compact phone ---------------------------------------- */
@media (max-width: 380px) {
  :root { --gutter: 1rem; }

  .hero h1 { font-size: 2.15rem; letter-spacing: -.035em; }
  .hero__badge { flex-wrap: wrap; }

  .dash { padding: .85rem .85rem 1rem; }
  .dash__metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash__metrics .metric:last-child { display: none; }
  .hviz__channels { gap: .35rem; }
  .chan__val { font-size: .82rem; }
  .pipe__val { font-size: .84rem; }

  .btn { padding: .85rem 1.3rem; }
  .footer__top { grid-template-columns: 1fr; }
  .socials a { width: 36px; height: 36px; }
}

/* ---------- Height-constrained viewports --------------------------------- */
@media (max-height: 620px) and (min-width: 1025px) {
  .hero { padding-top: calc(var(--header-h) + 2rem); padding-bottom: 3rem; }
}

/* ---------- Pointer-coarse refinements ----------------------------------- */
@media (hover: none) {
  /* Hover-only elevation is noise on touch devices */
  .card:hover,
  .ind-card:hover,
  .case-card:hover,
  .post-card:hover,
  .tst:hover,
  .prod-tile:hover,
  .panel-row:hover,
  .contact-row:hover { transform: none; }

  .btn:hover { transform: none; }
  .fab:hover { transform: none; }
}
