/* Layout stability layer
   Purpose: keep top/bottom bars and core grid consistent across common devices
   without touching the existing visual theme defined in style.css. */

/* Header edge-to-edge + footer bar basics */
html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

/* Prevent width jumps when page content height changes (scrollbar appears/disappears) */
html {
  overflow-y: auto;
  scrollbar-gutter: stable both-edges;
}

/* Outer shell is a single fixed-width grid track (content cannot resize it) */
body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

/* Keep outer shell fixed to viewport width, independent of injected center content */
body > header,
body > nav,
body > .main-content,
body > footer.site-footer-bar {
  grid-column: 1;
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  box-sizing: border-box;
}

body > nav .container-fluid {
  width: 100%;
  max-width: 100% !important;
  margin: 0 !important;
}

/* Global grid lock: keep main layout full-width regardless of zoom/page */
.main-content {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  box-sizing: border-box;
}

/* Keep a stable desktop grid across zoom levels */
@media (min-width: 1024px) {
  .main-content {
    grid-template-columns: clamp(220px, 16vw, 285px) minmax(0, 1fr) clamp(210px, 15vw, 275px);
    gap: 1rem;
    padding: 1rem;
  }
}

/* Prevent injected page content from forcing grid columns wider */
.main-content > * {
  min-width: 0;
}

#content,
.content,
.menu,
.right-rail-column,
#menu2 {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.main-content > .content {
  justify-self: stretch;
}

/* Dynamic page fragments must use the full content width */
#content {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
  overflow-x: hidden;
}

#content > * {
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  margin-left: 0 !important;
  margin-right: 0 !important;
  box-sizing: border-box;
}

#content form,
#content .contact-form-grid {
  width: 100% !important;
  max-width: none !important;
}

#content .section,
#content .document-page-section,
#content .document-browser,
#content .access-page,
#content .schedule-page,
#content .contact-directory-page {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

header {
  width: 100%;
  box-sizing: border-box;
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  overflow: hidden;
}

.site-footer-bar {
  grid-row: 4;
  width: 100%;
  box-sizing: border-box;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  overflow: hidden;
  padding: 0.75rem 1rem;
  text-align: center;
  color: #fff;
  background: linear-gradient(
    135deg,
    var(--portal-primary-strong, var(--oq-primary-strong, var(--secondary-color))) 0%,
    var(--portal-primary, var(--oq-primary, var(--secondary-color))) 55%,
    #744766 100%
  );
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 -10px 24px rgba(63, 32, 53, 0.18);
}

.site-footer-bar p {
  margin: 0;
  color: inherit;
  font-family: "Aptos", "Segoe UI", "Trebuchet MS", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

@media (max-width: 780px) {
  .site-footer-bar {
    padding: 0.68rem 0.85rem;
  }

  .site-footer-bar p {
    font-size: 0.82rem;
  }
}

/* Viewport-fit tuning */
body {
  min-height: 100vh;
  min-height: 100dvh;
}

@media (min-width: 1024px) {
  .main-content { align-items: stretch; }

  .content {
    min-height: 100%;
  }
}

header::after {
  display: none;
}

/* Responsive hardening for common devices (tablet, laptop, full HD) */
@media (max-width: 1023px) {
  .main-content {
    align-items: start;
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    padding: 0.95rem;
    gap: 0.9rem;
  }

  .menu,
  .content,
  .right-rail-column,
  #menu2 {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .right-rail-column {
    order: 3;
  }

  .content {
    min-height: 0;
  }
}

@media (min-width: 1024px) and (max-width: 1440px) {
  .main-content {
    grid-template-columns: clamp(210px, 15vw, 260px) minmax(0, 1fr) clamp(200px, 14vw, 250px);
    padding: 1rem;
    gap: 0.95rem;
  }

  header {
    min-height: 82px;
    padding: 0.9rem 1.2rem;
  }

  .site-footer-bar {
    padding: 0.62rem 0.9rem;
  }
}

@media (min-width: 1024px) and (max-height: 820px) {
  .main-content {
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
  }

  .content,
  .menu,
  #menu2 {
    padding: 1rem;
  }

  .home-shell {
    gap: 0.9rem;
  }
}
