/* =====================================================================
   InstaUPI — Responsive layer
   Breakpoints: 1440 · 1200 · 1024 · 860 · 768 · 600 · 430 · 375 · 320
   ===================================================================== */

/* Fallback if animation scripts fail to load */
.reveal-fallback [data-reveal] { opacity: 1 !important; transform: none !important; }

/* ---------- Large desktop (1920) ---------- */
@media (min-width: 1600px) {
  :root { --container: 1320px; }
  .hero-stage { min-height: 640px; }
}

/* ---------- Laptop (≤1280) ---------- */
@media (max-width: 1280px) {
  .footer-grid { grid-template-columns: 1.4fr repeat(3, 1fr); }
  .footer-contact { grid-column: 1 / -1; }
  .footer-contact ul { grid-auto-flow: column; justify-content: start; gap: 2.5rem; }
  .stage-dashboard { left: -8%; }
  .fc-hook { right: -6%; }
}

/* ---------- Small laptop / large tablet (≤1100) ---------- */
@media (max-width: 1100px) {
  .header-inner { grid-template-columns: auto 1fr auto; }
  .nav-link { padding: .5rem .75rem; }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .bento-hero { grid-row: auto; }
  .uc-row { grid-template-columns: repeat(2, 1fr); }
  .why-list { grid-template-columns: 1fr; gap: 1.25rem; }
  .why-list li { flex-direction: row; gap: 1rem; }
  .w-icon { flex: none; }
}

/* ---------- Tablet (≤1024): switch to mobile navigation ---------- */
@media (max-width: 1024px) {
  :root { --header-h: 70px; }
  .header-inner { grid-template-columns: auto 1fr; }
  .header-actions { grid-column: 2; }
  .header-actions > .btn { display: none; }
  .nav-toggle { display: block; }

  .primary-nav {
    justify-self: stretch; margin: 0;
    width: calc(100vw - (2 * var(--gutter))); max-width: none; min-width: 0;
    position: fixed; z-index: 99; top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 8px);
    left: var(--gutter); right: var(--gutter);
    max-height: calc(100dvh - var(--header-h) - 32px); overflow-y: auto;
    padding: 1rem; border-radius: 24px; background: #fff; box-shadow: var(--sh-3); border: 1px solid var(--line);
    opacity: 0; visibility: hidden; transform: translateY(-12px) scale(.98); transform-origin: top center;
    transition: opacity .3s var(--ease), transform .35s var(--ease), visibility 0s .35s;
  }
  .primary-nav.is-open { opacity: 1; visibility: visible; transform: none; transition: opacity .3s var(--ease), transform .35s var(--ease), visibility 0s; }
  .nav-list { flex-direction: column; gap: .15rem; padding: 0; background: none; border: 0; }
  .nav-link { padding: .9rem 1rem; font-size: 1.05rem; border-radius: 14px; }
  .nav-link.is-active { box-shadow: none; background: var(--blue-50); color: var(--blue); }
  .nav-link.is-active::after { left: auto; right: 1rem; top: 50%; bottom: auto; width: 8px; height: 8px; border-radius: 50%; transform: translateY(-50%); }
  .nav-actions-mobile .btn-ghost { --_bd: var(--line-strong); }
  .nav-actions-mobile { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
  .primary-nav.is-open .nav-list li { animation: navIn .4s var(--ease) both; }
  .primary-nav.is-open .nav-list li:nth-child(2) { animation-delay: .04s; }
  .primary-nav.is-open .nav-list li:nth-child(3) { animation-delay: .08s; }
  .primary-nav.is-open .nav-list li:nth-child(4) { animation-delay: .12s; }
  .primary-nav.is-open .nav-list li:nth-child(5) { animation-delay: .16s; }
  @keyframes navIn { from { opacity: 0; transform: translateY(-6px); } }

  /* Hero stacks: copy first, stage second */
  .hero-inner { grid-template-columns: 1fr; }
  .hero-copy { text-align: center; }
  .hero-title { margin-inline: auto; max-width: 16ch; }
  .hero-title::after { margin-inline: auto; }
  .hero-lead { margin-inline: auto; }
  .hero-ctas, .hero-points { justify-content: center; }
  .hero-stage { min-height: 620px; max-width: 640px; width: 100%; margin-inline: auto; }
  .stage-dashboard { left: 0; }
  .fc-hook { right: 0; }
  .fc-qr { left: 2%; }
  .illustration-note { text-align: center; }
  .hero-bg-art { right: 50%; transform: translate(50%, 0); top: auto; bottom: -10%; width: 900px; max-width: none; }

  .section-head.split { grid-template-columns: 1fr; gap: 1rem; }
  .section-head.split .section-lead { margin-top: .2rem; }

  .dark-inner, .dev-inner, .why-inner, .about-inner { grid-template-columns: 1fr; }
  .dark-visual { max-width: 620px; margin-inline: auto; width: 100%; }
  .why-visual { order: 2; max-width: 620px; width: 100%; margin-inline: auto; }
  .why-list { grid-template-columns: 1fr 1fr; }
  .why-list li { flex-direction: column; }
  .about-visual { max-width: 600px; width: 100%; margin-inline: auto; }
  .mission-card { left: 1rem; }

  .faq-inner { grid-template-columns: 1fr; }
  .faq-side { position: static; }

  .contact-inner { grid-template-columns: 1fr; }
  .contact-info { grid-template-columns: repeat(3, 1fr); }
  .info-card { flex-direction: column; }

  .cta-panel { grid-template-columns: 1fr; text-align: left; }
  .cta-actions { flex-direction: row; flex-wrap: wrap; }
}

/* ---------- Tablet portrait (≤860) ---------- */
@media (max-width: 860px) {
  .steps { grid-template-columns: 1fr 1fr; gap: 2.5rem 1.5rem; }
  .steps-track { display: none; }
  .uc-grid { grid-template-columns: 1fr; }
  .uc-reverse { flex-direction: column; }
  .footer-grid { grid-template-columns: 1fr 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
  .footer-brand p { max-width: 52ch; }
}

/* ---------- Tablet small (≤768) ---------- */
@media (max-width: 768px) {
  .bento { grid-template-columns: 1fr; }
  .bento-hero, .bento-wide { grid-column: auto; }
  .bento-wide { grid-template-columns: 1fr; }
  .dark-benefits { grid-template-columns: 1fr; gap: 1.25rem; }
  .contact-info { grid-template-columns: 1fr; }
  .info-card { flex-direction: row; }
  .contact-form { border-radius: var(--r-card); }
  .form-foot { flex-direction: column-reverse; align-items: stretch; }
  .form-foot .btn { width: 100%; }
  .form-hint { max-width: none; text-align: center; }
}

/* ---------- Mobile (≤600) ---------- */
@media (max-width: 600px) {
  :root { --r-panel: 24px; --r-card: 18px; }
  .brand-logo { width: 132px; }

  .hero { padding-top: calc(var(--header-h) + 2rem); }
  .hero-badge { font-size: .8rem; margin-bottom: 1.2rem; }
  .hero-ctas { flex-direction: column; }
  .hero-ctas .btn { width: 100%; }
  .hero-points { flex-direction: column; align-items: center; gap: .55rem; }

  /* Mobile hero stage: phone centred, satellites tucked in */
  .hero-stage { min-height: 560px; margin-top: 1rem; }
  .phone { width: 252px; height: 516px; border-radius: 42px; }
  .phone-screen { border-radius: 32px; padding: 50px 16px 18px; }
  .ps-qr { width: 168px; }
  .stage-dashboard { display: none; }
  .fc-qr { left: -2px; top: auto; bottom: 7%; transform-origin: left; }
  .fc-hook { right: -2px; top: 9%; }
  .float-card { padding: .55rem .8rem .55rem .55rem; border-radius: 14px; gap: .5rem; }
  .fc-icon { width: 32px; height: 32px; border-radius: 10px; }
  .float-card b { font-size: .78rem; }
  .float-card small { font-size: .68rem; }

  .steps { grid-template-columns: 1fr; gap: 0; }
  .step { display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto auto; column-gap: 1.1rem; text-align: left; padding: 0 0 2rem; }
  .step::before { content: ""; position: absolute; left: 31px; top: 70px; bottom: 8px; width: 2px; background: repeating-linear-gradient(180deg, var(--line-strong) 0 6px, transparent 6px 12px); }
  .step:last-child::before { display: none; }
  .step-icon { grid-row: 1 / 4; width: 64px; height: 64px; border-radius: 20px; margin: 0; }
  .step-icon::before { display: none; }
  .step-num { margin: .35rem 0 .2rem; }
  .step p { margin: 0; max-width: none; }

  .req-stack { height: 220px; }
  .bento-card { padding: 1.4rem; }
  .bento-hero { padding: 1.6rem; }
  .bento-visual { min-height: 190px; margin-top: .5rem; }

  .uc-row { grid-template-columns: 1fr; }
  .uc-body { padding: 1.4rem; }

  .console-body { grid-template-columns: 1fr; }
  .console-sum { max-width: 200px; width: 100%; justify-self: center; }
  .df-1 { right: 4%; }

  .editor-bar { flex-wrap: wrap; }
  .copy-btn span { display: none; }
  .code .line::before { width: 2.4rem; padding-right: .8rem; }

  .why-list { grid-template-columns: 1fr; }
  .why-list li { flex-direction: row; }
  .why-chip { right: 8px; top: -14px; }
  .mc-split { gap: 1rem; }
  .mc-donut { width: 96px; }

  .about-visual { padding-bottom: 0; }
  .mission-card { position: relative; left: auto; width: auto; margin: -2.5rem 1rem 0; }

  .acc-btn { padding: 1.05rem 1.1rem; }
  .acc-content p { padding: 0 1.1rem 1.15rem; }

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

  .cta-actions { flex-direction: column; }
  .cta-actions .btn { width: 100%; }

  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem 1.5rem; }
  .footer-contact ul { grid-auto-flow: row; }
  .footer-bottom-inner { flex-direction: column; align-items: flex-start; }
}

/* ---------- Small mobile (≤430 / 375) ---------- */
@media (max-width: 430px) {
  .hero-title { letter-spacing: -.04em; }
  .phone { width: 236px; height: 488px; }
  .ps-qr { width: 156px; }
  .ps-total strong { font-size: 1.3rem; }
  .fc-qr { bottom: 4%; }
  .info-card { padding: 1.15rem; }
}
@media (max-width: 375px) {
  .float-card small { display: none; }
  .nav-actions-mobile { grid-template-columns: 1fr; }
  .dark-float { font-size: .74rem; padding: .5rem .8rem; }
  .console-list li { grid-template-columns: 1fr auto; }
  .console-list em { display: none; }
}

/* ---------- 320 ---------- */
@media (max-width: 340px) {
  :root { --gutter: 1rem; }
  .brand-logo { width: 116px; }
  .phone { width: 220px; height: 460px; padding: 9px; }
  .phone-screen { padding: 46px 13px 16px; }
  .ps-qr { width: 142px; padding: 10px; }
  .fc-hook { display: none; }
  .footer-grid { grid-template-columns: 1fr; }
  .req b { font-size: 1.1rem; }
}

/* Touch devices: no hover lifts that stick */
@media (hover: none) {
  .bento-card:hover, .uc-card:hover, a.info-card:hover, .btn:hover { transform: none; }
}

/* Grid children must be allowed to shrink below their content width */
.hero-inner > *, .dark-inner > *, .dev-inner > *, .why-inner > *, .about-inner > *, .faq-inner > *, .contact-inner > * { min-width: 0; }
@media (max-width: 430px) {
  .btn { white-space: normal; text-align: center; }
  .dev-copy .btn { width: 100%; }
}
