/* ==========================================================================
   Purpose Health · Responsive Design & PageLoader System
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Branded PageLoader
   -------------------------------------------------------------------------- */
#ph-page-loader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 35%, rgba(0, 196, 179, 0.16) 0%, transparent 65%),
              radial-gradient(ellipse at 80% 80%, rgba(24, 95, 165, 0.12) 0%, transparent 65%),
              #FFFFFF;
  user-select: none;
  transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

#ph-page-loader.ph-loader-done {
  opacity: 0;
  transform: scale(1.02);
  pointer-events: none;
}

.ph-radar-core {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ph-ring-outer {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--teal, #00C4B3);
  border-right-color: rgba(0, 196, 179, 0.35);
  animation: ph-spin-cw 3.5s linear infinite;
}

.ph-ring-inner {
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-bottom-color: var(--heading, #185FA5);
  border-left-color: rgba(0, 196, 179, 0.7);
  animation: ph-spin-ccw 2.2s linear infinite;
}

.ph-compass-capsule {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px -5px rgba(24, 95, 165, 0.18);
  border: 1px solid var(--border, #E2E8F0);
  animation: ph-pulse 2s ease-in-out infinite;
  padding: 10px;
  box-sizing: border-box;
}

.ph-compass-capsule img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ph-loader-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--surface, #F8FAFC);
  border: 1px solid var(--border, #E2E8F0);
  color: var(--accent, #185FA5);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ph-loader-ping {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal, #00C4B3);
  box-shadow: 0 0 8px var(--teal, #00C4B3);
  animation: ph-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.ph-progress-track {
  width: 220px;
  height: 6px;
  background: #E2E8F0;
  border-radius: 9999px;
  overflow: hidden;
  margin: 16px auto 8px;
  padding: 1px;
  box-sizing: border-box;
}

.ph-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #00C4B3 0%, #185FA5 100%);
  transition: width 0.05s linear;
}

.ph-progress-text {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-2, #64748B);
  text-align: center;
}

@keyframes ph-spin-cw {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes ph-spin-ccw {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

@keyframes ph-pulse {
  0%, 100% { transform: scale(0.94); }
  50% { transform: scale(1.04); }
}

@keyframes ph-ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   2. Responsive Header & Mobile Hamburger Drawer
   -------------------------------------------------------------------------- */
.mm-hamburger-btn {
  display: none;
  background: var(--surface-card, #FFFFFF);
  border: 1.5px solid var(--border, #CBD5E1);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  color: var(--text, #0F172A);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease;
  z-index: 101;
}

.mm-hamburger-btn:hover {
  background: var(--surface-2, #F1F5F9);
  border-color: var(--teal, #00C4B3);
}

.mm-mobile-drawer {
  position: fixed;
  top: 0;
  right: -100%;
  width: min(88vw, 390px);
  height: 100vh;
  height: 100dvh;
  background: #FFFFFF;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.2);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  padding: 20px 24px 40px;
  box-sizing: border-box;
}

.mm-mobile-drawer.open {
  right: 0 !important;
}

.mm-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mm-drawer-backdrop.open {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.mm-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border, #E2E8F0);
  margin-bottom: 16px;
}

.mm-drawer-close {
  background: transparent;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-2, #64748B);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mm-drawer-close:hover {
  background: #F8FAFC;
  color: #0F172A;
}

.mm-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mm-drawer-section {
  border-bottom: 1px solid var(--border, #F1F5F9);
  padding-bottom: 10px;
}

.mm-drawer-title {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent, #185FA5);
  margin-bottom: 8px;
  font-weight: 700;
}

.mm-drawer-link {
  display: block;
  padding: 7px 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text, #1E293B);
  text-decoration: none;
}

.mm-drawer-link:hover {
  color: var(--teal, #00C4B3);
}

/* --------------------------------------------------------------------------
   3. Hero Carousel & Zoom-Safe Containers (Desktop & Baseline)
   -------------------------------------------------------------------------- */
.hero-carousel-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--bg-3, #E8F1FA);
  min-height: 560px;
}

.hero-inner-wrapper {
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 560px;
  box-sizing: border-box;
}

.hero-compass-img {
  position: absolute;
  top: 50%;
  right: 48px;
  transform: translateY(-50%);
  width: clamp(280px, 24vw, 420px);
  max-height: 85%;
  height: auto;
  opacity: 0.9;
  pointer-events: none;
  z-index: 1;
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.hero-slide {
  position: absolute;
  inset: 0;
  padding: 44px 48px 74px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.hero-slide.active {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.hero-text-container {
  position: relative;
  z-index: 3;
  max-width: min(58vw, 840px);
}

.hero-controls-dots {
  position: absolute;
  bottom: 28px;
  right: 148px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.hero-controls-dots button {
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hero-controls-arrows {
  position: absolute;
  bottom: 22px;
  right: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.hero-controls-arrows button {
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.hero-controls-arrows button:hover {
  background: var(--surface-2, #F1F5F9) !important;
  border-color: var(--teal, #00C4B3) !important;
  transform: translateY(-1px);
}

/* Announcement bar 1400px alignment to match header & hero */
section:has(.btn-cta-sm[href*="show"]) .container,
section:has(a[href*="events"]) .container {
  max-width: 1400px;
}

/* Inner pages hero containment for zoom-out safety */
main > section[style*="var(--bg-3)"] {
  position: relative;
  overflow: hidden;
}

main > section[style*="var(--bg-3)"] > .container {
  position: relative;
}

/* --------------------------------------------------------------------------
   4. Responsive Media Queries (Tablets & Mobile)
   -------------------------------------------------------------------------- */

@media (max-width: 1080px) {
  .mmbar {
    padding: 8px 18px !important;
  }
  .mmitems {
    display: none !important;
  }
  .mm-hamburger-btn {
    display: inline-flex !important;
  }
}

@media (max-width: 600px) {
  .mmbar {
    padding: 6px 12px !important;
  }
  .mmbar img {
    height: 38px !important;
  }
  .btn-cta-sm {
    padding: 7px 13px !important;
    font-size: 0.78rem !important;
  }
  .mm-hamburger-btn {
    padding: 5px 9px !important;
    font-size: 18px !important;
  }
}


@media (max-width: 992px) {
  .grid3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .grid4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .grid5 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  
  /* Hero section responsiveness */
  .hero-carousel-wrap {
    min-height: 520px !important;
  }
  .hero-compass-img {
    width: 220px !important;
    right: 2% !important;
    opacity: 0.35 !important;
  }
  .hero-text-container {
    max-width: 90% !important;
  }
  .hero-text-container h1,
  .hero-text-container h2 {
    max-width: 100% !important;
  }
  .hero-text-container p {
    max-width: 80% !important;
  }
}

@media (max-width: 768px) {
  /* Fluid padding for sections */
  section {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
  .container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
  }
  
  /* Responsive Hero */
  .hero-carousel-wrap {
    min-height: 560px !important;
    padding-bottom: 60px !important;
  }
  .hero-slide {
    padding: 30px 16px !important;
  }
  .hero-text-container {
    max-width: 100% !important;
  }
  .hero-text-container h1,
  .hero-text-container h2 {
    max-width: 100% !important;
  }
  .hero-text-container h1 span,
  .hero-text-container h2 span {
    white-space: normal !important;
    word-break: break-word !important;
  }
  .hero-text-container p {
    max-width: 100% !important;
    font-size: 16px !important;
  }
  .hero-compass-img {
    width: 180px !important;
    right: -20px !important;
    top: 65% !important;
    opacity: 0.18 !important;
  }
  .hero-controls-dots {
    left: 20px !important;
    right: auto !important;
    bottom: 16px !important;
  }
  .hero-controls-arrows {
    right: 20px !important;
    bottom: 12px !important;
  }
  
  /* Grids */
  .grid2 {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .grid3 {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .grid4 {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .grid5 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  /* Footer */
  footer div[style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 24px !important;
  }
}

@media (max-width: 480px) {
  .hero-carousel-wrap {
    min-height: 600px !important;
  }
  .hero-text-container .btn-cta,
  .hero-text-container .btn-outline {
    width: 100% !important;
    justify-content: center !important;
    font-size: 16px !important;
    padding: 10px 18px !important;
  }
  footer div[style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Chatbot responsive window on small mobile */
  #ph-chat-window {
    width: calc(100vw - 20px) !important;
    max-height: 82vh !important;
    right: 10px !important;
    bottom: 10px !important;
  }
}
