/* ============================================================
   CYBERFORTIFY · GLOBAL RESPONSIVE OVERRIDES
   Loaded last on every page. Hardens mobile/tablet behavior
   across all pages: index, services, frameworks, blog, policy.
   ============================================================ */

/* ---- Universal overflow & word-break safety ---- */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video, canvas, iframe { max-width: 100%; height: auto; }
iframe { width: 100%; }
pre, code, kbd, samp { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
pre { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table { max-width: 100%; }
.table-wrap, .scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Long URLs / monospace strings shouldn't blow out columns */
article a, .card a, p a, li a { word-break: break-word; overflow-wrap: anywhere; }

/* ---- Honey hexagon grid (compliance certs) — fix odd-count spans ---- */
@media (max-width: 1100px) {
  .honey { grid-template-columns: repeat(2, 1fr) !important; gap: 18px !important; }
  .honey > .hex-cert { grid-column: span 1 !important; aspect-ratio: 1 / 1.1 !important; }
  .honey > .hex-cert:nth-child(even) { transform: translateY(24px) !important; }
}
@media (max-width: 560px) {
  .honey { grid-template-columns: 1fr !important; gap: 14px !important; }
  .honey > .hex-cert { grid-column: span 1 !important; aspect-ratio: auto !important; min-height: 220px; }
  .honey > .hex-cert:nth-child(even) { transform: none !important; }
}

/* ---- Comparison matrix (.cmp-row) — single-column on mobile with labels ---- */
@media (max-width: 600px) {
  .cmp-head { display: none !important; }
  .cmp-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    border: 1px solid var(--border, rgba(39,175,232,.18)) !important;
    margin-bottom: 16px !important;
    border-radius: 10px;
    overflow: hidden;
  }
  .cmp-row .cell {
    grid-column: 1 / -1 !important;
    padding: 14px 16px !important;
    border-right: 0 !important;
    border-bottom: 1px solid var(--border-2, rgba(39,175,232,.08)) !important;
  }
  .cmp-row .cell:last-child { border-bottom: 0 !important; }
  .cmp-row .cell.us { order: -1; background: rgba(44,217,123,.06); }
}

/* ---- Tablet: <=1024px ---- */
@media (max-width: 1024px) {
  :root { --maxw: 100%; }
  .container, .wrap, .inner { padding-left: 24px; padding-right: 24px; }
  /* Force any 4-col grid to 2 */
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns: repeat(4"] { grid-template-columns: repeat(2, 1fr) !important; }
  /* Force any 3-col grid to 2 */
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns: repeat(3"] { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ---- Mobile: <=768px ---- */
@media (max-width: 768px) {
  body { font-size: 15px; line-height: 1.65; }
  h1 { font-size: clamp(1.9rem, 8vw, 2.6rem) !important; line-height: 1.08 !important; }
  h2 { font-size: clamp(1.5rem, 6vw, 2rem) !important; line-height: 1.15 !important; }
  h3 { font-size: clamp(1.15rem, 5vw, 1.45rem) !important; }

  /* Universal grid collapse */
  [class*="grid"]:not(.honey):not(.foot-grid):not(.process-flow),
  [class*="-grid"] { grid-template-columns: 1fr !important; }

  /* Horizontal padding tighten */
  section, .section, .s-inner, .content-area, .page-hero,
  .related-block, .cta-band, footer.site-foot, .cta-sec, .hero {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }
  .hero, .page-hero { padding-top: 100px !important; padding-bottom: 56px !important; }

  /* Buttons stack & full width */
  .hero-actions, .cta-btns, .btn-row, .actions {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .btn-main, .btn-ghost, .nav-btn, button.cta, a.cta {
    width: 100% !important;
    justify-content: center !important;
    text-align: center;
  }

  /* Tables: horizontal scroll, never overflow viewport */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  table thead, table tbody, table tr { display: table-row-group; }
  table tr { display: table-row; }
  table th, table td { display: table-cell; }

  /* Cards / panels — soften padding */
  .card, .panel, .hex-card, .ind-card, .hex-cert, .t-feat, .t-mini, .qmini,
  .vp, .kc, .tac, .pt, .ct, .toc, .pillar, .feature, .deliverable, .step,
  .related-card, .blog-card { padding: 22px 18px !important; }

  /* TOC sticky → static on mobile */
  .toc { position: static !important; top: auto !important; max-height: none !important; }

  /* Forms */
  form input, form textarea, form select, .contact-form input,
  .contact-form textarea, .contact-form select {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .form-row, .form-grid { grid-template-columns: 1fr !important; }

  /* Disable hover-translate transforms that look broken on touch */
  *:hover { transform: none !important; }

  /* Hide decorative cursors / orbit visuals on small screens */
  #cursor, #cursor-ring { display: none !important; }
  body { cursor: auto !important; }
  .orbit-visual, .shield-wrap, .hero-visual.decor-only { display: none !important; }

  /* Footer columns */
  .foot-grid { grid-template-columns: 1fr !important; gap: 28px !important; }
  .foot-bottom { flex-direction: column !important; gap: 10px !important; align-items: flex-start !important; }

  /* Submenu mega → stacked */
  .submenu.mega { grid-template-columns: 1fr !important; min-width: auto !important; }

  /* Mobile menu width */
  .mobile-menu { width: 100% !important; max-width: 100% !important; }

  /* Long inline KBD/code chips */
  .chip, .tag, .pill, .badge { font-size: .68rem !important; }

  /* Blog post images & figures */
  figure, .figure, .post-img { margin-left: 0 !important; margin-right: 0 !important; }
  figure img { width: 100%; }

  /* Reduce huge decorative numbers */
  .vp-num, .kc-num { font-size: 2rem !important; }
}

/* ---- Small mobile: <=480px ---- */
@media (max-width: 480px) {
  body { font-size: 14.5px; }
  h1 { font-size: clamp(1.7rem, 9vw, 2.2rem) !important; }
  h2 { font-size: clamp(1.35rem, 7vw, 1.7rem) !important; }
  section, .section, .s-inner, .content-area, .page-hero,
  .related-block, .cta-band, footer.site-foot, .cta-sec, .hero {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
  .hero, .page-hero { padding-top: 92px !important; padding-bottom: 44px !important; }
  .breadcrumb { font-size: .62rem !important; gap: 6px !important; }
  .hero-tag { font-size: .6rem !important; padding: 6px 12px 6px 6px !important; }
  .nav-btn { padding: 8px 12px !important; font-size: .6rem !important; }
  .logo-img { height: 48px !important; }
  nav.site-nav, nav { height: 64px !important; padding-left: 14px !important; padding-right: 14px !important; }
  .menu-btn-mob { width: 38px !important; height: 38px !important; }

  /* Stat strips collapse fully */
  .hero-stats, .stats { grid-template-columns: 1fr !important; }
  .hero-stat, .stat-item { border-right: 0 !important; }

  /* Cards slimmer */
  .card, .panel, .hex-card, .ind-card { padding: 18px 14px !important; }

  /* Pull-quotes */
  .pullquote, blockquote { padding: 22px 16px 22px 22px !important; font-size: 1rem !important; }

  /* Code blocks */
  pre { font-size: .72rem !important; padding: 14px !important; }
  code { font-size: .8em !important; }
}

/* ---- Touch-device polish ---- */
@media (hover: none) and (pointer: coarse) {
  /* Make touch targets at least 44px tall */
  a, button, .nav-btn, .btn-main, .btn-ghost,
  .mobile-menu a, .submenu a {
    min-height: 44px;
  }
  /* Show submenus by tap rather than hover */
  .nav-item .submenu { transition: none; }
}

/* ---- Landscape phone (short viewport) ---- */
@media (max-height: 480px) and (orientation: landscape) {
  .hero, .page-hero { padding-top: 90px !important; padding-bottom: 40px !important; }
  .mobile-menu { padding-top: 60px !important; }
}

/* ---- Print-safe (bonus) ---- */
@media print {
  nav, .mobile-menu, .mobile-overlay, #cursor, #cursor-ring, #scroll-progress,
  .ticker-band, footer.site-foot, .cta-band { display: none !important; }
  body { color: #000 !important; background: #fff !important; }
}
