/* ============================================================
 * Discovery AI — mobile / tablet layer
 * Loaded LAST, after styles/site.css.
 *
 * Every layout rule lives inside a max-width media query, so a
 * desktop browser never applies anything from this file. The only
 * rules outside a media query are base styles for the mobile nav
 * drawer — brand-new elements that have no desktop appearance.
 *
 * Breakpoints: 1100 (tablet) / 768 (phone landscape) / 480 (phone)
 * ============================================================ */

/* ---------- New elements: mobile nav (inert on desktop) ---------- */
.nav-burger {
  display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 10px;
  background: rgba(255,255,255,.7); color: var(--black-100);
  padding: 0;
}
.nav-burger:active { background: var(--primary-10); border-color: var(--primary-40); }
.nav-burger i { display: block; width: 18px; height: 1.5px; background: currentColor; border-radius: 2px; transition: transform .22s ease, opacity .16s ease; }
.nav-burger i + i { margin-top: 5px; }
.nav-burger[aria-expanded="true"] i:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-burger[aria-expanded="true"] i:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] i:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.nav-scrim {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: rgba(22,19,49,.45);
  opacity: 0; pointer-events: none; transition: opacity .24s ease;
}
.nav-scrim[data-open="1"] { opacity: 1; pointer-events: auto; }

.nav-drawer {
  display: none; position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: 85%; max-width: 380px;
  flex-direction: column;
  background: #fff;
  box-shadow: -26px 0 60px -24px rgba(22,19,49,.32);
  transform: translateX(101%);
  transition: transform .26s cubic-bezier(.32,.72,0,1);
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.nav-drawer[data-open="1"] { transform: translateX(0); }
.nav-drawer-hd {
  display: flex; align-items: center; justify-content: space-between;
  height: 72px; padding: 0 20px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.nav-drawer-hd img { height: 26px; }
.nav-drawer-close {
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: var(--black-5); color: var(--black-80);
  display: grid; place-items: center; font-size: 20px; line-height: 1;
}
.nav-drawer-links { display: flex; flex-direction: column; padding: 12px 12px 4px; }
.nav-drawer-link {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; padding: 0 12px;
  font-size: 17px; font-weight: 500; color: var(--black-100);
  border-radius: 12px;
}
.nav-drawer-link:active { background: var(--primary-10); }
.nav-drawer-link.is-active { background: var(--primary-10); color: var(--primary-100); }
.nav-drawer-link .chev {
  width: 7px; height: 7px; border-right: 1.5px solid var(--black-20);
  border-bottom: 1.5px solid var(--black-20); transform: rotate(-45deg);
}
.nav-drawer-foot {
  margin-top: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid var(--border); background: #fafaff;
}
.nav-drawer-foot .btn { width: 100%; justify-content: center; height: 50px; }

/* ================= TABLET — 1024px and below ================= */
@media (max-width: 1100px) {
  .container, .container-wide { padding: 0 24px; }
  .section { padding: 96px 0; }
  .section-sm { padding: 64px 0; }
  .section-tight { padding: 48px 0; }

  /* Nav: swap the inline links for the drawer trigger */
  .nav-links { display: none; }
  .nav-burger { display: flex; }
  .nav-scrim, .nav-drawer { display: flex; }
  .nav-inner { padding: 0 24px; }
  .nav-right { gap: 10px; }

  /* Three- and five-up card grids fall to two columns */
  [style*="repeat(3,"], [style*="repeat(5,"], [style*="repeat(4,"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .steps-5 > div { border-right: 1px solid var(--border) !important; }
  .steps-5 > div:nth-child(2n) { border-right: 0 !important; }
  .steps-5 > div:nth-child(n+3) { border-top: 1px solid var(--border) !important; }

  .hero-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 44px; }
  .hero-mark { width: 520px; right: -160px; }
  .foot-cols { grid-template-columns: 1.6fr minmax(0,1fr) minmax(0,1fr) !important; gap: 32px; }
  .cta-band { padding: 56px 36px; }
}

/* ================= PHONE — 768px and below ================= */
@media (max-width: 768px) {
  .container, .container-wide { padding: 0 20px; }
  .section { padding: 64px 0; }
  .section-sm { padding: 48px 0; }
  .section-tight { padding: 40px 0; }

  /* --- Collapse every multi-column inline grid to a single column.
     Excluded: icon/label rows that begin with a fixed px track
     (e.g. "28px 1fr", "44px 1fr auto") — those must stay side by side. */
  [style*="grid-template-columns"]:not([style*="px 1fr"]) {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 16px;
  }
  /* Rows with a fixed icon column AND a fixed label column need the
     label column released (Microsoft stack rows: 44px 220px 1fr). */
  [style*="220px 1fr"]:not([style*="zzz"]) { grid-template-columns: 34px minmax(0, 1fr) !important; gap: 12px !important; row-gap: 4px !important; }
  [style*="220px 1fr"] > div:nth-child(2) { grid-column: 2; }
  [style*="220px 1fr"] > div:nth-child(3) { grid-column: 2; }
  /* Anything explicitly re-laid-out below opts back in. */
  .demo-panes.demo-panes, .arch-nodes.arch-nodes { grid-template-columns: none !important; }

  /* Sticky side columns become normal flow */
  [style*="position: sticky"] { position: static !important; }

  /* --- Display type --- */
  .display-xl { font-size: 40px; letter-spacing: -0.028em; line-height: 1.05; }
  .display-lg { font-size: 34px; letter-spacing: -0.024em; line-height: 1.08; }
  .display-md { font-size: 28px; letter-spacing: -0.02em; }
  .display-sm { font-size: 22px; }
  .lede { font-size: 17px; }
  .body-lg { font-size: 16px; }
  .stat-num { font-size: 48px; }
  h1 br, h2 br { display: none; }

  /* --- Hero --- */
  .hero-wrap { padding: 48px 0 40px; }
  .hero-grid { gap: 36px; }
  .hero-mark { width: 380px; right: -120px; top: -40px; opacity: 0.06; }
  .hero-mark-backdrop { width: 440px !important; height: 460px !important; left: -140px !important; top: -70px !important; }
  .ambient-ellipse { width: 460px !important; height: 320px !important; filter: blur(60px); }

  /* --- Buttons: full-width stacks, 48px+ tap targets --- */
  .btn { min-height: 48px; }
  .btn-sm { min-height: 44px; }
  .btn-lg { height: 52px; font-size: 15px; }
  .hero-grid .btn, .cta-band .btn { width: 100%; justify-content: center; }
  .hero-grid [style*="display: flex"][style*="gap"] > .btn { flex: 1 1 100%; }

  /* --- CTA band --- */
  .cta-band { padding: 40px 24px; border-radius: 20px; }
  .cta-band::before { inset: -30% -20% auto auto; width: 90%; }

  /* --- Home: review demo — swipeable frame --- */
  .mock-frame { overflow: hidden; }
  .mock-titlebar { overflow-x: auto; scrollbar-width: none; }
  .mock-titlebar::-webkit-scrollbar { display: none; }
  .demo-panes.demo-panes {
    display: grid !important;
    grid-template-columns: 84vw 92vw !important;
    min-height: 460px !important;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity; overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .demo-panes::-webkit-scrollbar { display: none; }
  .demo-panes > * { scroll-snap-align: start; }
  .swipe-hint {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--black-40);
    padding: 10px 2px 0; justify-content: center;
  }

  /* --- Architecture: lanes stack, nodes swipe --- */
  .arch-lane { padding: 16px 16px 14px !important; }
  .arch-lane-hd { flex-wrap: wrap; gap: 8px; }
  .arch-nodes.arch-nodes {
    display: flex !important; gap: 10px !important;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin: 0 -16px; padding: 0 16px 4px;
    scroll-snap-type: x proximity; scrollbar-width: none;
  }
  .arch-nodes::-webkit-scrollbar { display: none; }
  .arch-nodes > button { flex: 0 0 156px; scroll-snap-align: start; }

  /* --- Product: 5-step strip stacks --- */
  .steps-5.steps-5 > div { border-right: 0 !important; border-top: 1px solid var(--border) !important; }
  .steps-5 > div:first-child { border-top: 0 !important; }

  /* --- Sign in --- */
  .signin-split.signin-split { min-height: 100vh; grid-template-columns: minmax(0, 1fr) !important; }
  .signin-form { padding: 24px 20px 32px !important; }
  .signin-brand { min-height: 220px; }
  .signin-brand > div { padding: 32px 24px !important; }
  .signin-brand p { font-size: 20px !important; }

  /* --- Forms: 16px prevents iOS zoom-on-focus --- */
  input, select, textarea { font-size: 16px !important; }
  input, select { min-height: 48px; }

  /* --- Footer --- */
  .site-footer { padding: 56px 0 32px; }
  .foot-cols { grid-template-columns: minmax(0,1fr) minmax(0,1fr) !important; gap: 28px 24px; margin-bottom: 36px; }
  .foot-cols > div:first-child { grid-column: 1 / -1; }
  .foot-bottom { flex-direction: column; align-items: flex-start; gap: 14px; }

  /* --- Tweaks panel: corner sheet --- */
  .twk-panel {
    width: min(300px, calc(100vw - 20px)) !important;
    right: 10px !important; bottom: 10px !important;
    max-height: 52vh !important;
  }
}

/* ================= SMALL PHONE — 480px and below ================= */
@media (max-width: 480px) {
  .container, .container-wide { padding: 0 16px; }
  .section { padding: 52px 0; }
  .section-sm { padding: 40px 0; }

  .display-xl { font-size: 33px; }
  .display-lg { font-size: 29px; }
  .display-md { font-size: 25px; }
  .lede { font-size: 16px; }
  .stat-num { font-size: 40px; }

  .nav-inner { height: 64px; padding: 0 16px; }
  .nav-brand img { height: 24px; }
  .nav-right .btn-ghost { display: none !important; }
  .nav-cta { height: 40px; padding: 0 14px; font-size: 13px; }

  .hero-wrap { padding: 36px 0 32px; }
  .hero-mark-backdrop { width: 360px !important; height: 380px !important; left: -110px !important; }
  .cta-band { padding: 32px 20px; border-radius: 18px; }
  .logo-strip { grid-template-columns: repeat(2, minmax(0,1fr)) !important; gap: 20px; }

  .demo-panes.demo-panes { grid-template-columns: 90vw 96vw !important; min-height: 420px !important; }
  .arch-nodes > button { flex: 0 0 140px; }

  .foot-cols { grid-template-columns: minmax(0,1fr) !important; }
  .foot-cols > div:first-child { grid-column: auto; }
  .twk-panel { max-height: 46vh !important; }
}
