/* Shared responsive layout fixes for Luvian presentation pages */

/* Safe-area support for notched phones */
html {
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ------------------------------------------------------------------ */
/* NDA footer — compact on small screens                              */
/* ------------------------------------------------------------------ */
@media (max-width: 480px) {
  .nda-footer {
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0));
    font-size: 7px;
    letter-spacing: 0.06em;
  }

  .nda-footer .nda-logo {
    display: none;
  }
}

/* ------------------------------------------------------------------ */
/* Sidebar financial pages                                            */
/* ------------------------------------------------------------------ */
@media (max-width: 767px) {
  main.ml-56,
  main.ml-60 {
    margin-left: 0 !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    padding-top: 3.5rem !important;
  }

  #sidebar {
    z-index: 70;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  }

  #nav-toggle {
    top: max(0.75rem, env(safe-area-inset-top, 0.75rem));
  }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 65;
}

.sidebar-backdrop.visible {
  display: block;
}

/* ------------------------------------------------------------------ */
/* Slide decks — scrollable, single-column grids on phones            */
/* ------------------------------------------------------------------ */
@media (max-width: 767px) {
  body.luvian-slide-deck {
    overflow: auto !important;
  }

  body.luvian-slide-deck .slide {
    min-height: 100dvh;
    height: auto !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    padding-bottom: 7rem !important;
  }

  body.luvian-slide-deck .slide .grid.grid-cols-3,
  body.luvian-slide-deck .slide .grid.grid-cols-4,
  body.luvian-slide-deck .slide .grid.grid-cols-2:not(.sm\:grid-cols-2):not(.lg\:grid-cols-5) {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }

  body.luvian-slide-deck .controls.fixed.bottom-6.right-6,
  body.luvian-slide-deck .controls.fixed.bottom-6.left-6 {
    bottom: max(5.5rem, calc(env(safe-area-inset-bottom, 0) + 4.5rem));
  }

  body.luvian-slide-deck #framing-toggle {
    top: max(0.75rem, env(safe-area-inset-top, 0.75rem));
    right: 0.75rem;
    max-width: calc(100vw - 1.5rem);
    flex-wrap: wrap;
    justify-content: center;
  }

  body.luvian-slide-deck #framing-toggle .frame-btn {
    font-size: 10px;
    padding: 4px 8px;
  }

  body.luvian-slide-deck .text-5xl {
    font-size: 1.875rem !important;
    line-height: 2.25rem !important;
  }

  body.luvian-slide-deck .text-4xl {
    font-size: 1.5rem !important;
    line-height: 2rem !important;
  }

  body.luvian-slide-deck .text-3xl {
    font-size: 1.25rem !important;
    line-height: 1.75rem !important;
  }
}

/* ------------------------------------------------------------------ */
/* Tables — horizontal scroll on narrow viewports                     */
/* ------------------------------------------------------------------ */
@media (max-width: 767px) {
  .luvian-table-scroll,
  main table,
  section table,
  .slide table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .overflow-hidden:has(table) {
    overflow-x: auto !important;
  }
}

/* ------------------------------------------------------------------ */
/* Document pages — tighter horizontal padding                        */
/* ------------------------------------------------------------------ */
@media (max-width: 767px) {
  .max-w-5xl.mx-auto.px-6,
  .max-w-6xl.mx-auto.px-6,
  .max-w-4xl.mx-auto.px-6 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .grid.grid-cols-2:not([class*="md:grid-cols"]):not([class*="sm:grid-cols"]),
  .grid.grid-cols-3:not([class*="md:grid-cols"]):not([class*="sm:grid-cols"]),
  .grid.grid-cols-4:not([class*="md:grid-cols"]):not([class*="sm:grid-cols"]) {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }
}

/* ------------------------------------------------------------------ */
/* Collab overlay — mobile bottom sheet + control spacing               */
/* ------------------------------------------------------------------ */
@media (max-width: 640px) {
  #luvian-collab-toggle-wrap {
    right: max(12px, env(safe-area-inset-right, 12px));
    bottom: max(5.5rem, calc(env(safe-area-inset-bottom, 0) + 4.5rem));
  }

  #luvian-collab-toggle {
    position: static;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  #luvian-collab-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: min(88dvh, calc(100dvh - env(safe-area-inset-top, 0)));
    max-height: 88dvh;
    border-left: none;
    border-top: 1px solid var(--collab-border, #e5e7eb);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.12);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  #luvian-collab-panel.open {
    transform: translateY(0);
  }

  #luvian-collab-panel:not(.open) {
    transform: translateY(100%);
  }

  #luvian-collab-presence {
    top: max(12px, env(safe-area-inset-top, 12px));
    right: max(12px, env(safe-area-inset-right, 12px));
    bottom: auto;
    max-width: calc(100vw - 5rem);
  }

  #luvian-collab-presence .presence-label {
    display: none;
  }

  #luvian-collab-selection {
    position: fixed;
    width: min(320px, calc(100vw - 16px));
    left: 8px !important;
    right: 8px;
    margin: 0 auto;
  }
}
