/* ==========================================================================
   RIGSAFELENS · UI REFINEMENTS
   Cross-page fixes: responsive overflow, accessibility, rhythm, typography.
   Loaded after style.css and nav-footer.css so it can refine page styles.
   ========================================================================== */

/* ---- Typography polish ---- */
h1, h2, h3, h4 { text-wrap: balance; }
p, li { text-wrap: pretty; }
::selection { background: var(--amber-soft); color: var(--text-primary); }

/* Anchored sections clear the fixed navbar */
html { scroll-padding-top: 80px; }

/* ---- Accessibility: visible keyboard focus ---- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 0;
}
.btn:focus-visible { outline-offset: 2px; border-radius: 0; }

/* Keyboard access to the Platform dropdown (desktop) */
@media (min-width: 993px) {
  .dropdown-wrap:focus-within .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
  .dropdown-wrap:focus-within .nav-link svg.arrow-icon { transform: rotate(180deg); }
  /* Invisible bridge so the menu doesn't close while the pointer crosses the gap */
  .dropdown-menu::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: -14px; height: 14px;
  }
}

/* Navbar gains depth once the page scrolls */
.navbar { transition: box-shadow 0.2s ease, background-color 0.2s ease; }
.navbar.scrolled {
  background: rgba(10, 14, 22, 0.88);
  box-shadow: 0 6px 20px -10px rgba(0, 0, 0, 0.6);
}

/* ---- Type rhythm ---- */
/* Large inline-styled numbers/headings get display leading instead of body leading */
[style*="font-size:var(--text-xl)"],
[style*="font-size:var(--text-2xl)"],
[style*="font-size:var(--text-3xl)"],
[style*="font-size:var(--text-4xl)"] { line-height: 1.15; }

/* Touch screens: full-size buttons reach the 44px minimum target (header buttons excluded) */
@media (pointer: coarse) {
  .btn:not(.btn-sm) { min-height: var(--control-lg); }
  .nav-cta .btn { min-height: 0; }
}

/* ---- Rhythm: remove the double gap between page heroes and the first section ---- */
.page-hero + .section,
.page-hero + .section-sm,
.page-hero + .section-tight { padding-top: 24px; }

/* ---- Badges & small labels never break mid-label ---- */
.badge,
.featured-tag,
.status-chip { white-space: nowrap; }

/* ---- Stacked heroes: centered copy, but product mockups keep left-aligned UI text ---- */
@media (max-width: 992px) {
  .hero-grid > :last-child,
  .hero-split > :last-child { text-align: left; }
}

/* ---- Responsive overflow guards ---- */
/* Grid/flex children default to min-width:auto, which lets long mono strings
   and nowrap buttons push columns past the viewport on phones. */
[class*="grid"] > *,
[class*="split"] > *,
[style*="display:grid"] > * { min-width: 0; }

pre,
.code-box {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

img, video { max-width: 100%; }

@media (max-width: 900px) {
  /* Inline two-column layouts collapse on tablet and below */
  [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; gap: 2.5rem !important; }
}

@media (max-width: 640px) {
  .wrap, .container, .wrap-narrow, .container-narrow { padding-left: 16px; padding-right: 16px; }

  .section { padding: 56px 0; }
  .section-sm { padding: 40px 0; }
  .card { padding: 24px; }

  /* Long uppercase mono labels and HUD rows wrap instead of overflowing */
  .badge, .status-chip, .featured-tag { white-space: normal; text-align: center; }
  .hud-tablet-bar, .hud-bottom-bar, .device-top-bar { gap: 8px; flex-wrap: wrap; }

  /* Full-width, stacked CTAs read cleaner than ragged wrapped buttons */
  .hero-actions .btn,
  .btn-lg { width: 100%; }
  .alert-actions-row { flex-wrap: wrap; }
  .alert-actions-row > * { flex: 1 1 140px; }

  /* Hero trust pills on the homepage */
  .meta-pills { flex-wrap: wrap; gap: 8px 16px; }

  /* Tables scroll horizontally inside their own box */
  .comparison-table { display: block; overflow-x: auto; white-space: nowrap; }

  .footer { padding-top: 48px; }
  .footer-meta { flex-direction: column; align-items: flex-start; }
}

/* ---- Motion preferences ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Typeface tuning: Archivo display, IBM Plex text ---- */
h1, h2, h3, h4, h5, h6, .logo-brand, [style*="--font-head"] {
  font-stretch: 112%;
  font-optical-sizing: auto;
}
h1 { letter-spacing: -0.025em; }
body { font-feature-settings: "kern", "liga"; }
code, kbd, samp, [style*="--font-mono"] { font-variant-numeric: tabular-nums slashed-zero; }
