/* ==========================================================
   Start Innovations — mobile overrides (≤ 640px)
   Scoped to small screens only. Keep desktop layout intact.
   ========================================================== */

/* Desktop defaults: hide mobile-only chrome */
.burger,
.m-drawer,
.m-drawer-scrim { display: none; }

@media (max-width: 640px) {

  .burger { display: inline-flex; }
  .m-drawer { display: flex; }
  .m-drawer-scrim { display: block; }

  :root {
    --pad: 20px;
    --maxw: 100%;
  }

  /* ---------- Header / burger ---------- */
  .site-header .inner { padding: 10px 16px; gap: 10px; }
  .site-header .nav { display: none; }
  .site-header .header-right .btn-primary,
  .site-header .header-right .theme-switch,
  .site-header .header-right .lang-switch { display: none; }
  .logo-link img,
  .brand-logo { height: 30px !important; }

  .burger {
    display: inline-flex;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: transparent;
  }
  .burger span {
    display: block;
    width: 16px; height: 1.5px;
    background: var(--fg);
    position: relative;
  }
  .burger span::before,
  .burger span::after {
    content: ""; position: absolute; left: 0;
    width: 16px; height: 1.5px; background: var(--fg);
  }
  .burger span::before { top: -5px; }
  .burger span::after  { top:  5px; }

  /* Drawer */
  .m-drawer-scrim {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    opacity: 0; pointer-events: none;
    transition: opacity .28s ease;
    z-index: 120;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
  .m-drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(320px, 86vw);
    background: var(--bg-elev, var(--bg));
    border-left: 1px solid var(--line-strong);
    z-index: 130;
    padding: 20px 24px 28px;
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform .32s cubic-bezier(.2,.7,.2,1);
    overflow-y: auto;
  }
  body.m-open .m-drawer { transform: translateX(0); }
  body.m-open .m-drawer-scrim { opacity: 1; pointer-events: auto; }
  body.m-open { overflow: hidden; }

  .m-drawer .m-top {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 28px;
  }
  .m-drawer .m-top img { height: 28px; width: auto; filter: invert(1); }
  [data-theme="light"] .m-drawer .m-top img { filter: none; }
  .m-drawer .m-close {
    width: 40px; height: 40px; display: inline-flex;
    align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 999px;
    color: var(--fg); font-size: 20px; line-height: 1;
  }

  .m-drawer nav { display: flex; flex-direction: column; }
  .m-drawer nav a {
    padding: 18px 0;
    font-family: var(--ff-display);
    font-size: 26px;
    letter-spacing: -0.02em;
    color: var(--fg);
    border-bottom: 1px solid var(--line);
  }
  .m-drawer nav a.active { color: var(--fg); }
  .m-drawer nav a:not(.active) { color: var(--fg-muted); }

  .m-drawer .m-ctrls {
    margin-top: auto; padding-top: 28px;
    display: flex; flex-direction: column; gap: 14px;
  }
  .m-drawer .m-ctrls .lang-switch,
  .m-drawer .m-ctrls .theme-switch { display: inline-flex; align-self: flex-start; }
  .m-drawer .m-ctrls .btn { justify-content: center; }

  /* ---------- Type scale ---------- */
  .h-display { font-size: clamp(44px, 13vw, 64px); }
  .h-xl      { font-size: clamp(34px, 9vw, 46px); }
  .h-lg      { font-size: clamp(28px, 7vw, 36px); }
  .h-md      { font-size: 20px; }
  section    { padding: 72px 0; }
  .section-head { margin-bottom: 36px; gap: 12px; }

  /* ---------- Hero ---------- */
  .hero { min-height: auto; padding-top: 90px; padding-bottom: 40px; }
  .hero .inner { padding-bottom: 24px; }
  .hero h1 { font-size: clamp(56px, 16vw, 84px) !important; line-height: 0.92; }
  .hero .hero-layout { grid-template-columns: 1fr !important; gap: 28px; }
  .hero .hero-side { display: none; } /* live card off on small screens */
  .hero .lede { font-size: 15px; }
  .hero .actions { flex-direction: column; align-items: stretch; }
  .hero .actions .btn { width: 100%; justify-content: center; min-height: 48px; }
  .hero .meta-row { flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 32px; padding-top: 16px; font-size: 10px; }
  .hero .meta-row .coord { gap: 14px; }

  /* Hide heavy type layer variant on mobile */
  html[data-hero="type"] .hero .type-layer { font-size: 40vw; }

  /* ---------- Stats ---------- */
  .stats .row { grid-template-columns: repeat(2, 1fr) !important; gap: 16px; }
  .stats .cell { padding: 6px 0 6px 14px; }
  .stats .num { font-size: 36px; }
  .stats .lab { font-size: 10px; }

  /* ---------- About ---------- */
  .about .grid { grid-template-columns: 1fr !important; gap: 28px; }
  .about .body { font-size: 20px; line-height: 1.38; }
  .about ul { margin-top: 24px; gap: 16px; }
  .about li { font-size: 14px; grid-template-columns: 28px 1fr; gap: 10px; }

  /* ---------- Products tabs ---------- */
  .prod .tabs { grid-template-columns: 1fr !important; gap: 0; }
  .prod .tablist {
    flex-direction: row;
    border-right: none !important;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding-bottom: 4px;
  }
  .prod .tablist::-webkit-scrollbar { display: none; }
  .prod .tab {
    flex: 0 0 auto;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    border-right: none;
    display: inline-flex;
    grid-template-columns: none;
    min-width: auto;
    gap: 8px;
  }
  .prod .tab[aria-selected="true"] {
    border-bottom-color: var(--fg);
  }
  .prod .tab .idx { font-size: 10px; }
  .prod .tab .name { font-size: 16px; }
  .prod .tab .arr { display: none; }
  .prod .panel { padding: 24px 0; min-height: auto; }
  .prod .panel h3 { font-size: 32px !important; }
  .prod .panel .mock { padding: 12px; min-height: auto; }
  .prod .panel .mock-grid { grid-template-columns: 1fr !important; gap: 8px; }
  .prod .panel .mock-cell { min-height: auto; padding: 12px; }
  .prod .panel .mock-cell .v { font-size: 22px; }

  /* ---------- Architecture canvas ---------- */
  .arch-wrap { border-radius: 6px; }
  .arch-wrap canvas { height: 420px !important; }
  .arch-wrap .label { font-size: 9px; top: 10px; left: 12px; }
  .arch-wrap .pulse { font-size: 9px; top: 12px; right: 12px; }

  /* ---------- Customers ---------- */
  .customers .logos { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .customers .cell { min-height: 92px; padding: 12px; }
  .customers .cell img { max-height: 48px; }
  .customers .marquee .track img { height: 60px; max-width: 130px; padding: 10px 14px; }

  /* ---------- CTA ---------- */
  .end-cta h2 { font-size: 40px !important; }
  .end-cta p { font-size: 15px; }
  .end-cta .btn { width: 100%; justify-content: center; }

  /* ---------- Footer ---------- */
  .site-footer { padding: 48px 0 28px; }
  .site-footer .cols { grid-template-columns: 1fr 1fr !important; gap: 28px; margin-bottom: 32px; }
  .site-footer .bottom { flex-direction: column; align-items: flex-start; gap: 10px; font-size: 9.5px; }
  .site-footer .big-mark { font-size: 68px !important; margin-top: 24px; }

  /* ---------- Page hero (products/cases/contacts) ---------- */
  .page-hero { padding: 110px 0 28px !important; }
  .page-hero h1 { font-size: clamp(40px, 11vw, 56px) !important; line-height: 0.95; }

  /* ---------- Product details (products.html) ---------- */
  .pr-grid, .pr-modules, .pr-details { grid-template-columns: 1fr !important; gap: 20px !important; }
  .pr-row { flex-direction: column !important; align-items: flex-start !important; gap: 16px !important; }

  /* ---------- Cases ---------- */
  .cases-grid, .case-grid { grid-template-columns: 1fr !important; gap: 16px !important; }
  .case-card { padding: 20px !important; }

  /* ---------- Contacts ---------- */
  .contact-grid, .contacts-grid { grid-template-columns: 1fr !important; gap: 28px !important; }
  form label { font-size: 13px; }
  form input, form textarea, form select {
    font-size: 16px !important; /* avoid iOS zoom */
    min-height: 44px;
  }
  form button[type="submit"] { width: 100%; min-height: 48px; }

  /* ---------- Tweaks panel ---------- */
  .tweaks-panel {
    right: 12px; left: 12px; bottom: 12px;
    width: auto !important;
  }

  /* ---------- Utility: min tap targets ---------- */
  .btn { min-height: 44px; }

  /* ---------- Hide desktop-only things ---------- */
  .m-hide-mobile { display: none !important; }
}
