/**
 * Global responsive layer — safe areas, readable type, app shell drawer, tables.
 * Load after app-baseline.css on all pages.
 */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

nav.sidebar,
aside.sidebar {
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.32s ease;
}

body {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Readable, fluid headings where pages use .view-header */
.view-header h1 {
  font-size: clamp(1.65rem, 5vw + 1rem, 2.5rem);
  line-height: 1.12;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.view-header p {
  max-width: 100%;
  font-size: clamp(0.9375rem, 0.6vw + 0.85rem, 1.1rem);
}

/* Main column: safe horizontal inset + width (vertical padding left to page blocks) */
body .main-view {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
}

@media (min-width: 640px) {
  body .main-view {
    padding-left: max(24px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(24px, env(safe-area-inset-right, 0px)) !important;
  }
}

@media (min-width: 1024px) {
  body .main-view {
    padding-left: 48px !important;
    padding-right: 48px !important;
  }
}

@media (min-width: 1280px) {
  body .main-view {
    padding-left: 80px !important;
    padding-right: 80px !important;
  }
}

/* Dashboard-style content rail */
body .content-area {
  max-width: 100%;
  box-sizing: border-box;
  padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
}

/* Docs-style hero titles */
.hero-h1 {
  font-size: clamp(2rem, 6vw + 1rem, 4.25rem) !important;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

/* Prose & code: no horizontal spill */
main,
.main-content,
.main-view,
section {
  overflow-wrap: break-word;
}

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

/* Config cards breathe on narrow screens */
.config-card {
  padding-left: clamp(16px, 4vw, 32px);
  padding-right: clamp(16px, 4vw, 32px);
}

/* Settings / billing field rows */
.field-control {
  flex-direction: column;
  align-items: stretch;
}

@media (min-width: 640px) {
  .field-control {
    flex-direction: row;
    align-items: center;
  }
}

/* Tables: horizontal scroll without breaking layout */
.vortex-table-scroll,
.activity-table-container {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
}

.vortex-table-scroll table,
.activity-table-container table {
  min-width: 560px;
}

@media (max-width: 640px) {
  table:not(.no-mobile-compact) th,
  table:not(.no-mobile-compact) td {
    padding: 12px 14px;
    font-size: 13px;
  }
}

/* Touch-friendly controls */
@media (pointer: coarse) {
  button:not(.vortex-touch-keep),
  .btn,
  input[type="submit"],
  .nav-link,
  .nav-item {
    min-height: 44px;
  }

  .nav-link,
  .nav-item {
    align-items: center;
  }
}

/* Mobile navigation FAB + backdrop */
.vortex-app-shell-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1998;
  background: rgba(0, 0, 0, 0.52);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.vortex-app-shell-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.vortex-app-menu-fab {
  display: none;
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 0px));
  left: max(14px, env(safe-area-inset-left, 0px));
  z-index: 1999;
  width: 46px;
  height: 46px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: #0d0d0d;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.vortex-app-menu-fab:hover {
  border-color: rgba(255, 255, 255, 0.45);
  background: #141414;
}

.vortex-app-menu-fab:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.vortex-app-menu-fab svg,
.vortex-app-menu-fab i {
  width: 22px;
  height: 22px;
  stroke: #ffffff;
}

@media (max-width: 768px) {
  .vortex-app-menu-fab {
    display: flex;
  }

  body.vortex-nav-drawer-open {
    overflow: hidden;
  }

  nav.sidebar.active,
  aside.sidebar.active {
    z-index: 2000;
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.55);
  }
}

@media (min-width: 769px) {
  .vortex-app-shell-backdrop.is-open {
    display: none !important;
  }
}

/* User menu slot should stay above FAB */
.vortex-user-slot--fixed {
  z-index: 2001;
}

/* Auth / register / contact centered cards */
@media (max-width: 480px) {
  body .back-home,
  body .back {
    top: max(12px, env(safe-area-inset-top, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    right: auto;
    font-size: 11px;
    padding: 8px 12px;
  }
}

/* Playground / marketing compact nav on small screens */
.site-header--fixed .nav-links a {
  font-size: clamp(10px, 2.5vw, 12px);
  letter-spacing: min(0.12em, 2px);
}

/* Billing plan cards */
.plans-grid {
  grid-template-columns: 1fr;
}

/* Reduce oversized doc section titles on mobile */
@media (max-width: 640px) {
  .docs-section h2 {
    font-size: 1.15rem;
    padding-left: 14px;
    margin: 32px 0 18px;
  }

  .view-header h1 {
    margin-bottom: 12px;
  }
}
