/* ------------------------------------------------------------------
   nano · shared responsive layer
   Linked from every Minimal-template page. Uses the same tokens
   that those pages already declare (--ink, --bg, --line, --line-2,
   --surface, --blue, --r-1, --dur, --ease, --sans).
   ------------------------------------------------------------------ */

/* Global hygiene */
html { -webkit-text-size-adjust: 100%; }
img, svg, video, canvas { max-width: 100%; }

/* ------------------------------------------------------------------
   Mobile nav (hamburger + drawer)
   .nav-toggle is injected by responsive.js into .nav-cta.
   ------------------------------------------------------------------ */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 36px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--line-2, #cdd5df);
  color: var(--ink, #0a0e16);
  cursor: pointer;
  font-family: inherit;
  transition: background 180ms cubic-bezier(0.2,0.7,0.2,1),
              border-color 180ms cubic-bezier(0.2,0.7,0.2,1);
}
.nav-toggle:hover { border-color: var(--ink, #0a0e16); }
.nav-toggle svg { width: 18px; height: 18px; display: block; }
.nav-toggle .icon-close { display: none; }

/* Drawer scrim — sits below the drawer, above the page */
.nav-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 16, 0.32);
  z-index: 40;
  animation: nav-scrim-in 180ms cubic-bezier(0.2,0.7,0.2,1);
}
@keyframes nav-scrim-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ------------------------------------------------------------------
   Mobile drawer (≤ 1024px)
   Editorial-style nav: numbered rows, big type, animated chevron,
   active page highlight, dedicated bottom action row.
   ------------------------------------------------------------------ */
@media (max-width: 1024px) {
  .nav-inner { gap: 16px !important; position: relative; }
  .nav-toggle { display: inline-flex; }

  /* When drawer is open, swap hamburger icon for close */
  .nav.is-open .nav-toggle .icon-open  { display: none; }
  .nav.is-open .nav-toggle .icon-close { display: block; }

  /* Drawer panel */
  .nav.is-open .nav-links {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    left: 0;
    right: 0;
    top: 64px;
    background: var(--surface, #fff);
    border-bottom: 1px solid var(--line, #e1e6ec);
    padding: 24px 24px 20px;
    gap: 0;
    box-shadow: 0 24px 32px -20px rgba(13, 13, 16, 0.18);
    z-index: 60;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    animation: nav-drawer-in 240ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  @keyframes nav-drawer-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Individual drawer rows. JS adds .drawer-num and .drawer-arrow. */
  .nav.is-open .nav-links a {
    display: grid;
    grid-template-columns: 36px 1fr 20px;
    align-items: center;
    gap: 16px;
    padding: 18px 4px;
    font-size: 19px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--ink, #0a0e16) !important;
    border-top: 1px solid var(--line, #e1e6ec);
    transition: color 180ms cubic-bezier(0.2, 0.7, 0.2, 1),
                background 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .nav.is-open .nav-links a:first-child { border-top: 0; }
  .nav.is-open .nav-links a:hover { color: var(--blue, #1c3a7a) !important; }
  .nav.is-open .nav-links a:active { background: rgba(28, 58, 122, 0.04); }

  /* Number marker (set by JS as data-attr; rendered with ::before) */
  .nav.is-open .nav-links a .drawer-num {
    font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", monospace;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-4, #97a0ab);
    letter-spacing: 0.04em;
    transition: color 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .nav.is-open .nav-links a:hover .drawer-num { color: var(--blue, #1c3a7a); }

  /* Chevron */
  .nav.is-open .nav-links a .drawer-arrow {
    justify-self: end;
    color: var(--ink-4, #97a0ab);
    transform: translateX(-4px);
    opacity: 0.6;
    transition: transform 200ms cubic-bezier(0.2, 0.7, 0.2, 1),
                opacity 180ms cubic-bezier(0.2, 0.7, 0.2, 1),
                color 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .nav.is-open .nav-links a:hover .drawer-arrow,
  .nav.is-open .nav-links a.is-current .drawer-arrow {
    transform: translateX(0);
    opacity: 1;
    color: var(--blue, #1c3a7a);
  }

  /* Active page */
  .nav.is-open .nav-links a.is-current {
    color: var(--blue, #1c3a7a) !important;
  }
  .nav.is-open .nav-links a.is-current .drawer-num {
    color: var(--blue, #1c3a7a);
  }

  /* Footer row (injected by JS) — Sign in + GitHub side by side */
  .nav.is-open .drawer-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 12px;
    padding: 18px 4px 6px;
    border-top: 1px solid var(--line, #e1e6ec);
    font-size: 14.5px;
  }
  .nav.is-open .drawer-foot a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-3, #5d6772) !important;
    padding: 0;
    border: 0;
    font-weight: 500;
    transition: color 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .nav.is-open .drawer-foot a:hover { color: var(--ink, #0a0e16) !important; }
  .nav.is-open .drawer-foot svg { width: 16px; height: 16px; }

  .nav.is-open ~ .nav-scrim { display: block; }
  body.nav-locked { overflow: hidden; }

  /* Tighten the right side so the toggle fits */
  .nav-cta {
    gap: 10px !important;
    margin-left: auto;
  }
  .nav-cta .btn { height: 34px; padding: 0 12px; font-size: 13.5px; }
}

/* ------------------------------------------------------------------
   Small tablet / large phone ≤ 720px
   ------------------------------------------------------------------ */
@media (max-width: 720px) {
  .wrap, .narrow, .wrap-wide { padding: 0 20px !important; }

  /* Hide signin link to free up space (still in drawer) */
  .nav-cta .signin { display: none; }
  /* Hide github icon at this width — still in drawer if we want later */
  .nav-cta > a[aria-label="GitHub"] { display: none; }

  /* Hero CTAs stack and stretch */
  .hero-cta { gap: 12px; }
  .hero-cta .btn { flex: 1 1 auto; min-width: 0; justify-content: center; }
  .hero-cta .tlink { margin-left: 0 !important; flex-basis: 100%; }

  /* Hero meta wraps tighter */
  .hero-meta { gap: 12px 18px !important; }

  /* Common section padding */
  section { padding: 72px 0; }

  /* Quote and OSS sections inner padding */
  .quote-inner,
  .oss-inner { padding: 0 20px !important; }
  .quote-section, .oss-section { padding: 80px 0 !important; }

  /* Pricing card stays usable */
  .pricing-card { padding: 28px 22px !important; }
  .pricing-card .price { font-size: 44px !important; }

  /* Lightweight stat numbers shrink */
  .lw-stat-num { font-size: 48px !important; }

  /* Footer always 1-col below this */
  .foot-top { grid-template-columns: 1fr !important; gap: 32px !important; padding-bottom: 40px !important; }
  .foot-bottom { flex-direction: column; align-items: flex-start; gap: 16px; }

  /* Hide gnarly "step-aside" copy on phones — it's secondary */
  .step .step-aside { display: none !important; }

}

/* Trust strip at tablet AND phone widths.
   Flex-wrap with explicit min-widths on the cells so the
   plain-SVG logos (AWS / Azure / GCP — no intrinsic width
   attribute) never collapse to zero. Gaps are generous so the
   two combined-mark cells (ClickHouse + Cloudflare) don't run
   into each other when they share a row. */
@media (max-width: 1024px) {
  .trust-row {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 28px 44px !important;
    grid-template-columns: none !important;
  }
  .trust-row .cell {
    flex: 0 0 auto;
    min-width: 92px;
    height: 32px;
  }
  /* Combined-mark cells (ClickHouse, Cloudflare) already have
     intrinsic width from their inline-height img tags. */
  .trust-row .cell--ch { min-width: 0; }
}
@media (max-width: 560px) {
  .trust-row {
    gap: 24px 36px !important;
  }
  .trust-row .cell { min-width: 76px; height: 26px; }
  .trust-row .cell img { max-height: 18px !important; }
  .trust-row .cell--ch img[style*="height: 22px"] { height: 19px !important; }
  .trust-row .cell--ch img[style*="height: 18px"] { height: 16px !important; }
  .trust-row .cell--ch img[style*="height: 16px"] { height: 14px !important; }
  .trust-row .cell--ch img[style*="height: 14px"] { height: 12px !important; }
}

/* ------------------------------------------------------------------
   Features page · "From signup to first detection" ladder.
   Desktop is a 5-col row connected by a horizontal line.
   On phone we rebuild it as a proper vertical timeline:
   smaller numbered nodes, a vertical thread between them,
   tighter type, generous rhythm.
   ------------------------------------------------------------------ */
@media (max-width: 720px) {
  .ladder {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
    padding: 0 !important;
    position: relative;
  }
  .ladder::before {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    top: 30px;
    bottom: 30px;
    left: 13px;            /* 28px circle / 2 = 14, minus 1 for the 2px line */
    width: 2px;
    height: auto !important;
    right: auto !important;
    background: var(--line-2, #cdd5df) !important;
    z-index: 0;
  }
  .ladder-step {
    grid-template-columns: 28px 1fr !important;
    grid-template-rows: auto auto !important;
    gap: 6px 16px !important;
    padding: 14px 0 !important;
    align-items: start !important;
    position: relative;
    z-index: 1;
  }
  .ladder-step + .ladder-step {
    border-top: 0;
  }
  .ladder-num {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    align-self: start;
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
    margin-bottom: 0 !important;
    margin-top: 2px;
    /* Solid background so the thread visually breaks at each node. */
    box-shadow: 0 0 0 4px var(--bg, #f1f3f6);
  }
  .ladder-step:not(:first-child) .ladder-num {
    background: var(--bg, #f1f3f6) !important;
  }
  .ladder-name {
    grid-column: 2 !important;
    grid-row: 1 !important;
    font-size: 16px !important;
    line-height: 1.3;
    margin-bottom: 0 !important;
    align-self: center;
    min-height: 32px;
    display: flex;
    align-items: center;
  }
  .ladder-detail {
    grid-column: 2 !important;
    grid-row: 2 !important;
    font-size: 14px !important;
    line-height: 1.55;
    color: var(--ink-3);
    max-width: 42ch;
  }
  .ladder-foot { margin-top: 32px !important; }
}

/* ------------------------------------------------------------------
   Phone ≤ 560px
   ------------------------------------------------------------------ */
@media (max-width: 560px) {
  .wrap, .narrow, .wrap-wide { padding: 0 16px !important; }
  .nav-inner { gap: 8px !important; }
  .nav-cta { gap: 6px !important; }
  .nav-cta .btn { padding: 0 10px; font-size: 13px; }

  /* Buttons go full-width by default for tap targets */
  .hero-cta { flex-direction: column; align-items: stretch; }
  .hero-cta .btn { width: 100%; }
  .hero-cta .tlink { justify-content: center; }

  /* Section pads tighter */
  section { padding: 56px 0 !important; }
  .hero { padding: 48px 0 32px !important; }
  .quote-section, .oss-section { padding: 64px 0 !important; }

  /* Pricing card: shrink price + button */
  .pricing-card { padding: 22px 18px !important; border-radius: 10px; }
  .pricing-card .price { font-size: 40px !important; }

  /* Stat tiles */
  .lw-stat-num { font-size: 40px !important; }

  /* Quote inner — let body type stay readable */
  .quote-inner blockquote { font-size: clamp(20px, 5.4vw, 26px) !important; }
}

/* ------------------------------------------------------------------
   Tabs row in hero figure: make it horizontally scrollable when
   tabs no longer fit on one line, instead of wrapping into stacks.
   ------------------------------------------------------------------ */
@media (max-width: 720px) {
  .tab-row {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tab-row::-webkit-scrollbar { display: none; }
  .tab {
    flex: 0 0 auto;
    padding: 12px 14px 14px !important;
    font-size: 13px !important;
  }
  .tab .tab-kbd { display: none; }
}

/* ------------------------------------------------------------------
   Tables: any large compare/spec table becomes horizontally
   scrollable in its own scroll container rather than overflowing
   the page. The pages add `.compare-table` themselves.
   ------------------------------------------------------------------ */
@media (max-width: 900px) {
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px;
    padding: 0 20px;
  }
}

/* Pricing page · comparison table polish on mobile.
   The page already makes .compare-wrap-mobile a horizontal scroll
   container at ≤720px. We add:
   - sticky first column so the feature name stays anchored
   - soft right-edge fade so the "swipe →" affordance reads
   - a few breathing-room tweaks to make cells feel less mashed */
@media (max-width: 720px) {
  .compare-wrap-mobile {
    position: relative;
    /* Right-edge fade: starts ~32px from the right and tapers out.
       Uses a wide mask covering the rest so the rest of the
       wrapper renders normally. */
    -webkit-mask-image: linear-gradient(
      to right,
      #000 0,
      #000 calc(100% - 28px),
      transparent 100%
    );
            mask-image: linear-gradient(
      to right,
      #000 0,
      #000 calc(100% - 28px),
      transparent 100%
    );
  }
  .compare-wrap-mobile .compare-table th:first-child,
  .compare-wrap-mobile .compare-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    /* Match page bg so the sticky column sits opaquely above
       horizontally-scrolled cells. */
    background: var(--bg, #f1f3f6);
    /* Hairline divider between sticky col and the scrolled cells */
    box-shadow: 1px 0 0 var(--line, #e1e6ec);
    /* Slightly tighter padding for the sticky column to save width */
    padding-right: 10px;
  }
  .compare-wrap-mobile .compare-table thead th:first-child {
    z-index: 3;
  }
}
