/* ═══════════════════════════════════════════════════════════
   KN-RESPONSIVE.CSS — Kronvex mobile responsive system
   Breakpoints: 768px · 480px · 390px
   ═══════════════════════════════════════════════════════════ */

/* ── Global: prevent overflow-x:hidden from breaking position:sticky ──
   overflow-x:clip clips without creating a scroll container, so
   position:sticky on nav children still works correctly.
   !important overrides any inline <style> body{overflow-x:hidden}    */
html { overflow-x: clip; scrollbar-gutter: stable; }
body { overflow-x: clip !important; }

/* ── Desktop nav: flex layout with absolutely-centered links ──
   Replaces the grid 1fr/auto/1fr approach which can produce uneven
   column widths depending on page-specific CSS context.              */
@media(min-width:769px) {
  #kn-nav {
    display: flex !important;
    justify-content: space-between !important;
  }
  .kn-links {
    position: absolute !important;
    left: 50% !important;
    top: 0 !important;
    height: 100% !important;
    transform: translateX(-50%) !important;
  }
}

/* ── ≤ 1280px — Tablet landscape / small desktop ── */
@media(max-width:1280px){

  /* ── Reduce hero padding ── */
  #hero { padding-left: clamp(24px, 5vw, 56px) !important; padding-right: clamp(24px, 5vw, 56px) !important; }

  /* ── Section inner: tighten padding ── */
  [style*="padding:0 80"],[style*="padding:0 80px"],
  [style*="padding: 0 80"],[style*="padding: 0 80px"] {
    padding-left: 40px !important; padding-right: 40px !important;
  }

  /* ── 4-col grids → 3 col ── */
  [style*="grid-template-columns:repeat(4,1fr)"]:not(#kn-nav),
  [style*="grid-template-columns: repeat(4, 1fr)"]:not(#kn-nav) {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  [style*="grid-template-columns:1.4fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr 1fr !important;
  }

  /* ── Pricing cards: ensure they don't squish ── */
  .plan-card { min-width: 0 !important; }

  /* ── Enterprise hero padding ── */
  .ent-hero { padding-left: 40px !important; padding-right: 40px !important; }

  /* ── Hide decorative pillars earlier ── */
  .kn-pillar { display: none !important; }
}

/* ── ≤ 768px — Tablet / large mobile ── */
@media(max-width:768px){

  /* ── Prevent horizontal overflow ── */
  html { overflow-x: clip; }
  body { overflow-x: clip !important; }

  /* ── Nav — sticky must survive overflow-x overrides ── */
  #kn-nav {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0 !important;
    padding: 0 16px !important;
    gap: 0 !important;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
  }
  .kn-links, .kn-lang, .kn-dash, .kn-login,
  .kn-logout-nav, .kn-get-demo { display: none !important; }
  .kn-hamburger { display: flex !important; }

  /* ── Logo — ensure visibility and sizing on mobile ── */
  .kn-logo { gap: 8px; font-size: 12px; }
  .kn-logo img { width: 24px; height: 32px; }

  /* ── Decorative elements — hide on mobile ── */
  #bg-canvas,
  #kn-canvas,
  .float-card,
  .kn-pillar,
  .kn-pillar-l,
  .kn-pillar-r { display: none !important; }

  /* Grain: halve opacity for performance */
  body::before { opacity: 0.012 !important; }

  /* ── Hero (index.html specific) ── */
  #hero { padding: 80px 20px 48px !important; min-height: auto !important; }
  .hero-inner {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
    padding: 0 !important;
  }
  .hero-right { display: none !important; }
  .hero-title {
    font-size: clamp(32px, 8vw, 52px) !important;
    letter-spacing: -1.5px !important;
  }
  .hero-sub { max-width: 100% !important; }

  /* ── CSS-class-based grids → 1 column ── */
  .demo-layout,
  .why-grid,
  .how-grid,
  .int-grid,
  .sdk-grid,
  .api-inner,
  .spec-grid,
  .use-grid,
  .compare-grid { grid-template-columns: 1fr !important; gap: 20px !important; }

  /* ── Sections: remove side padding (inner wrapper handles it) ── */
  section, .section { padding-left: 0 !important; padding-right: 0 !important; }

  /* ── Tables: horizontal scroll ── */
  table {
    display: block !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    max-width: 100% !important;
  }

  /* ── Code blocks: horizontal scroll ── */
  pre, .code-line, .terminal-body, .code-block, .sdk-code {
    overflow-x: auto !important;
    white-space: pre !important;
    max-width: 100% !important;
  }

  /* ── Inputs ── */
  input, select, textarea {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Footer: 2 cols at 768px ── */
  .footer-top { grid-template-columns: 1fr 1fr !important; gap: 24px !important; }

  /* ── Inline padding overrides (targets common section wrapper patterns) ── */
  [style*="padding:0 80"],[style*="padding: 0 80"],[style*="padding:0 80px"],[style*="padding: 0 80px"] { padding-left: 16px !important; padding-right: 16px !important; }
  [style*="padding:0 72"],[style*="padding: 0 72"],[style*="padding:0 72px"],[style*="padding: 0 72px"] { padding-left: 16px !important; padding-right: 16px !important; }
  [style*="padding:0 64"],[style*="padding: 0 64"],[style*="padding:0 64px"],[style*="padding: 0 64px"] { padding-left: 16px !important; padding-right: 16px !important; }
  [style*="padding:0 56"],[style*="padding: 0 56"],[style*="padding:0 56px"],[style*="padding: 0 56px"] { padding-left: 16px !important; padding-right: 16px !important; }
  [style*="padding:0 48"],[style*="padding: 0 48"],[style*="padding:0 48px"],[style*="padding: 0 48px"] { padding-left: 16px !important; padding-right: 16px !important; }
  [style*="padding:0 40"],[style*="padding: 0 40"],[style*="padding:0 40px"],[style*="padding: 0 40px"] { padding-left: 16px !important; padding-right: 16px !important; }

  /* ── Inline grid column overrides ── */
  [style*="grid-template-columns:repeat(3,1fr)"]:not(#kn-nav),
  [style*="grid-template-columns: repeat(3, 1fr)"]:not(#kn-nav) {
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
  }
  [style*="grid-template-columns:repeat(4,1fr)"]:not(#kn-nav),
  [style*="grid-template-columns: repeat(4, 1fr)"]:not(#kn-nav) {
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
  }
  [style*="grid-template-columns:1.4fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
  }

  /* ── Footer inline grid → 2 cols ── */
  footer [style*="display:grid"],
  footer [style*="display: grid"] { grid-template-columns: 1fr 1fr !important; gap: 20px !important; }

  /* ── Max-width containers: ensure they don't bleed ── */
  [style*="max-width:1080px"],
  [style*="max-width:1200px"],
  [style*="max-width:960px"],
  [style*="max-width:900px"] {
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  /* ── Blog article layout ── */
  .article-wrap { padding: 24px 16px 64px !important; }
  .article-cta   { padding: 28px 20px !important; }
  .kv-related-grid { grid-template-columns: 1fr !important; }

  /* ── Search overlay: full width on mobile ── */
  #kn-search-overlay .kn-search-box,
  [id*="search"] [class*="box"],
  [id*="search"] [class*="inner"] { width: min(92vw, 600px) !important; }

  /* ── Compare pages: table horizontal scroll ── */
  .compare-wrap, .compare-table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
  .compare-table { min-width: 600px !important; }
  .compare-table td:first-child, .compare-table th:first-child {
    position: sticky !important; left: 0 !important;
    background: var(--bg2, #141b26) !important; z-index: 1 !important;
  }

  /* ── Modals: full width ── */
  .kn-modal, .modal-inner, .modal-box, [class*="modal"][class*="inner"],
  [class*="modal"][class*="box"] {
    width: min(92vw, 640px) !important;
    max-width: 92vw !important;
    margin: 16px auto !important;
  }

  /* ── Horizontal flex rows → column ── */
  .kn-cta-row, .cta-row, .action-row { flex-direction: column !important; gap: 12px !important; }

  /* ── Enterprise/about section wrappers ── */
  .ent-hero, .ent-inner, [class*="ent-wrap"] { padding-left: 16px !important; padding-right: 16px !important; }
  [style*="padding:72px 0"],[style*="padding: 72px 0"],
  [style*="padding:96px 0"],[style*="padding: 96px 0"] {
    padding-top: 48px !important; padding-bottom: 48px !important;
  }

  /* ── 2-col inline grids → keep 2 col until 480px ── */
  [style*="grid-template-columns:repeat(2,1fr)"]:not(#kn-nav),
  [style*="grid-template-columns: repeat(2, 1fr)"]:not(#kn-nav) {
    gap: 14px !important;
  }

  /* ── Blog sidebar: disable sticky on mobile (becomes a block) ── */
  #kn-blog-sidebar {
    position: static !important;
    height: auto !important;
    overflow-y: visible !important;
  }

}

/* ── ≤ 480px — Standard iPhone ── */
@media(max-width:480px){

  /* ── Typography ── */
  h1 { font-size: clamp(28px, 7vw, 42px) !important; }
  h2 { font-size: clamp(22px, 5.5vw, 32px) !important; }
  p { font-size: 14px !important; line-height: 1.65 !important; }

  /* ── Hero actions → full width column ── */
  .hero-actions { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; margin-bottom: 28px !important; }
  .btn-primary, .btn-ghost { width: 100% !important; justify-content: center !important; text-align: center !important; }

  /* ── Hero stats: 2×2 grid ── */
  .hero-stats { display: grid !important; grid-template-columns: 1fr 1fr !important; }
  .hero-stat { border-right: none !important; border-bottom: 1px solid var(--border2) !important; padding: 13px 10px !important; }
  .hero-stat:nth-child(odd) { border-right: 1px solid var(--border2) !important; }
  .hero-stat:nth-last-child(-n+2) { border-bottom: none !important; }

  /* ── CTA buttons ── */
  .kn-cta-btns, .cta-btns, .hero-ctas { flex-direction: column !important; width: 100% !important; }
  .kn-cta-btns a, .cta-btns a, .hero-ctas a { width: 100% !important; text-align: center !important; display: block !important; }

  /* ── Demo layout ── */
  .demo-layout { gap: 24px !important; }
  .d-row { grid-template-columns: 1fr !important; }

  /* ── Why angles: keep 2 cols ── */
  .why-angles { grid-template-columns: 1fr 1fr !important; }

  /* ── Footer: 1 column ── */
  .footer-top { grid-template-columns: 1fr !important; gap: 20px !important; }
  footer [style*="display:grid"],
  footer [style*="display: grid"] { grid-template-columns: 1fr !important; gap: 16px !important; }

  /* ── Inline grids → 1 col on small phones ── */
  [style*="grid-template-columns:1fr 1fr"]:not(#kn-nav) { grid-template-columns: 1fr !important; gap: 14px !important; }
  [style*="grid-template-columns:repeat(3,1fr)"]:not(#kn-nav) { grid-template-columns: 1fr !important; gap: 14px !important; }
  [style*="grid-template-columns:repeat(4,1fr)"]:not(#kn-nav) { grid-template-columns: 1fr !important; gap: 14px !important; }

  /* ── Disable hover transforms on touch devices ── */
  @media(hover:none){
    .plan-card:hover, .feat-card:hover, .int-card:hover,
    .sdk-card:hover, .ep-card:hover, .ep-box:hover,
    .problem-card:hover, .reason-card:hover { transform: none !important; box-shadow: none !important; }
  }

  /* ── Reduce backdrop-filter on non-nav elements (performance) ── */
  .float-card, .hero-badge, .hero-stats { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }

  /* ── 2-col inline grids → 1 col on phones ── */
  [style*="grid-template-columns:repeat(2,1fr)"]:not(#kn-nav),
  [style*="grid-template-columns: repeat(2, 1fr)"]:not(#kn-nav) {
    grid-template-columns: 1fr !important; gap: 14px !important;
  }

  /* ── Compare table: reset sticky (scroll handles it) ── */
  .compare-table td:first-child, .compare-table th:first-child { position: static !important; }

  /* ── Inline section titles: tighten margins ── */
  [style*="margin-bottom:56px"],[style*="margin-bottom: 56px"] { margin-bottom: 32px !important; }
  [style*="margin-bottom:48px"],[style*="margin-bottom: 48px"] { margin-bottom: 28px !important; }

  /* ── Code font size ── */
  pre, code, .code-body, [class*="code"][class*="body"] { font-size: 12px !important; }

  /* ── Dashboard stats row ── */
  .db-stats, [id*="dash"][class*="stats"], [class*="stat-row"] {
    grid-template-columns: 1fr 1fr !important; gap: 12px !important;
  }

  /* ── Section padding ── */
  section, .section { padding-top: 48px !important; padding-bottom: 48px !important; }

  /* ── Bento boxes: reduce padding for more compact layout ── */
  .bento { padding: 18px 14px !important; }
  .bento h3 { font-size: 17px !important; }
  .bento p { font-size: 13px !important; }

  /* ── Metric cards: compact ── */
  .metric-card { padding: 24px 10px !important; }
  .metric-num { font-size: clamp(24px, 8vw, 36px) !important; }
  .metric-desc { font-size: 11px !important; }

  /* ── How cards: compact ── */
  .how-card { padding: 20px 14px !important; }

  /* ── Section inner titles ── */
  .sec-title { letter-spacing: -1.5px !important; }

  /* ── Ensure all buttons are full width for easy tapping ── */
  .plan-btn { padding: 12px 8px !important; font-size: 9px !important; }
}

/* ── ≤ 390px — iPhone SE / small screens ── */
@media(max-width:390px){

  /* ── Tighten horizontal padding ── */
  [style*="padding:0 80"],[style*="padding: 0 80"],[style*="padding:0 80px"],[style*="padding: 0 80px"],
  [style*="padding:0 72"],[style*="padding: 0 72"],[style*="padding:0 72px"],[style*="padding: 0 72px"],
  [style*="padding:0 64"],[style*="padding: 0 64"],[style*="padding:0 64px"],[style*="padding: 0 64px"],
  [style*="padding:0 56"],[style*="padding: 0 56"],[style*="padding:0 56px"],[style*="padding: 0 56px"],
  [style*="padding:0 48"],[style*="padding: 0 48"],[style*="padding:0 48px"],[style*="padding: 0 48px"],
  [style*="padding:0 40"],[style*="padding: 0 40"],[style*="padding:0 40px"],[style*="padding: 0 40px"] { padding-left: 12px !important; padding-right: 12px !important; }

  [style*="max-width:1080px"],
  [style*="max-width:1200px"],
  [style*="max-width:960px"],
  [style*="max-width:900px"] { padding-left: 12px !important; padding-right: 12px !important; }

  /* ── Typography minimum ── */
  h1 { font-size: clamp(24px, 8vw, 32px) !important; letter-spacing: -1px !important; }
  h2 { font-size: clamp(20px, 6vw, 28px) !important; }

  /* ── Hero ── */
  #hero { padding: 64px 12px 40px !important; }
  .hero-stat { padding: 12px 10px !important; }
  .hero-title { letter-spacing: -1px !important; }

  /* ── Section padding ── */
  section, .section { padding-top: 44px !important; padding-bottom: 44px !important; }
}
