/* Custom iOS & Apple-Inspired Design System for House of Hope */
/* Typography is loaded via parallel preconnected <link> tags in HTML <head> for zero-waterfall instant FCP */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
}

body {
  font-family: var(--font-sans);
  background-color: #FAF8F5; /* Warm Apple off-white/linen */
  color: #18191B;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Apple-style Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

/* Apple Navbar: Transparent at top -> Frosted Glass on Scroll */
#mainHeader {
  transition: background-color 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              backdrop-filter 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              padding 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

#mainHeader.is-transparent {
  background-color: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  box-shadow: none !important;
}

/* Header Adaptive Brand Logo (White on Dark Hero, Navy on Scrolled Header) */
#mainHeader.is-transparent #heroLogoLight {
  display: block !important;
}
#mainHeader.is-transparent #heroLogoDark {
  display: none !important;
}

#mainHeader.is-scrolled #heroLogoLight {
  display: none !important;
}
#mainHeader.is-scrolled #heroLogoDark {
  display: block !important;
}

/* Base Desktop Nav Pill Wrapper */
.nav-pill-wrapper {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 4px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569 !important;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 9999px;
  font-size: 0.75rem; /* 12px */
  line-height: 1rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  white-space: nowrap;
}

.nav-link:hover {
  color: #0F172A !important;
  background: rgba(0, 0, 0, 0.05) !important;
}

/* Global Active Nav Link Pill (Unmistakable Apple Segmented Control Style) */
.nav-link.active-nav-link {
  background: #FFFFFF !important;
  color: #0F172A !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px -1px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08) !important;
  border: 1px solid rgba(0, 0, 0, 0.04) !important;
}

/* Glowing Orange Dot Indicator on Active Desktop Nav Tab */
.nav-link.active-nav-link::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background-color: #EA580C;
  margin-right: 6px;
  box-shadow: 0 0 6px rgba(234, 88, 12, 0.8);
  flex-shrink: 0;
}

/* Transparent Header Over Hero (index.html top) */
#mainHeader.is-transparent .nav-pill-wrapper {
  background: rgba(0, 0, 0, 0.28) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

#mainHeader.is-transparent .nav-link {
  color: rgba(255, 255, 255, 0.9) !important;
}

#mainHeader.is-transparent .nav-link:hover {
  color: #FFFFFF !important;
  background: rgba(255, 255, 255, 0.2) !important;
}

#mainHeader.is-transparent .nav-link.active-nav-link {
  background: #FFFFFF !important;
  color: #0F172A !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3) !important;
  border: 1px solid rgba(255, 255, 255, 0.6) !important;
}

#mainHeader.is-transparent .nav-link.active-nav-link::before {
  background-color: #EA580C;
  box-shadow: 0 0 8px rgba(234, 88, 12, 0.9);
}

#mainHeader.is-transparent .mobile-menu-toggle {
  color: #FFFFFF !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Scrolled Header (Frosted Glass on scroll) */
#mainHeader.is-scrolled {
  background-color: rgba(255, 255, 255, 0.88) !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
  backdrop-filter: blur(24px) !important;
  -webkit-backdrop-filter: blur(24px) !important;
  box-shadow: 0 4px 20px -2px rgba(24, 25, 27, 0.05) !important;
}


#mainHeader.is-scrolled .nav-pill-wrapper {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.06) !important;
}

#mainHeader.is-scrolled .nav-link {
  color: #475569 !important;
}

#mainHeader.is-scrolled .nav-link:hover {
  color: #0F172A !important;
  background: rgba(0, 0, 0, 0.06) !important;
}

#mainHeader.is-scrolled .nav-link.active-nav-link {
  background: #FFFFFF !important;
  color: #0F172A !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px -1px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06) !important;
}

#mainHeader.is-scrolled .mobile-menu-toggle {
  color: #1E293B !important;
  background: rgba(0, 0, 0, 0.05) !important;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Mobile Drawer Menu Active Link */
.mobile-nav-active {
  background-color: #FFF7ED !important;
  color: #EA580C !important;
  border: 1px solid #FFEDD5 !important;
  font-weight: 700 !important;
}
.mobile-nav-active i {
  color: #EA580C !important;
}

/* Mobile Bottom Tab Dock Bar Active Link */
.dock-link.active {
  color: #EA580C !important;
  font-weight: 700 !important;
}
.dock-link.active i {
  color: #EA580C !important;
  stroke-width: 2.5 !important;
}
.dock-link.active span {
  color: #EA580C !important;
  font-weight: 700 !important;
}

/* Touch & Mobile Responsiveness Optimizations */
* {
  -webkit-tap-highlight-color: transparent;
}

button, a, .dock-link, .nav-link, .ios-btn-primary, .ios-btn-accent {
  touch-action: manipulation;
}

@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important; /* Prevents auto-zoom on mobile iOS Safari */
  }
}

/* Mobile Safe-Area and Dock Clearance */
.ios-dock {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
  padding-bottom: max(0.5rem, calc(env(safe-area-inset-bottom, 0px) * 0.5));
}

@media (max-width: 767px) {
  footer {
    padding-bottom: max(7rem, calc(5.5rem + env(safe-area-inset-bottom, 1.5rem))) !important;
  }
}

/* Glassmorphism Classes */
.glass-header {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.glass-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 20px -2px rgba(24, 25, 27, 0.04), 0 2px 6px -1px rgba(24, 25, 27, 0.02);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -4px rgba(24, 25, 27, 0.08), 0 4px 12px -2px rgba(24, 25, 27, 0.03);
}

.glass-pill {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* iOS Segmented Control & Buttons */
.ios-segmented-btn.active {
  background: #FFFFFF;
  color: #0F172A;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ios-btn-primary {
  background: #111827;
  color: #FFFFFF;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ios-btn-primary:hover {
  background: #1F2937;
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(17, 24, 39, 0.2);
}

.ios-btn-primary:active {
  transform: scale(0.98);
}

.ios-btn-accent {
  background: linear-gradient(135deg, #FF6B4A 0%, #EE5A36 100%);
  color: #FFFFFF;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 14px rgba(238, 90, 54, 0.3);
}

.ios-btn-accent:hover {
  filter: brightness(1.05);
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(238, 90, 54, 0.4);
}

.ios-btn-accent:active {
  transform: scale(0.98);
}

/* iOS Dynamic Island Toast Animation */
@keyframes dynamicIslandIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -24px) scale(0.85);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, 4px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

@keyframes dynamicIslandOut {
  0% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -20px) scale(0.9);
  }
}

.dynamic-toast {
  animation: dynamicIslandIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dynamic-toast.dismissing {
  animation: dynamicIslandOut 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}



/* Shimmer & Glow Effects: Apple-Inspired Skeleton Loading System */
@keyframes skeletonShimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes skeletonPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* Base Skeleton Shimmer Element */
.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    #F1F5F9 0%,
    #E2E8F0 25%,
    #F8FAFC 50%,
    #E2E8F0 75%,
    #F1F5F9 100%
  );
  background-size: 250% 100%;
  animation: skeletonShimmer 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Dark Shimmer for Hero & Dark Cards */
.skeleton-shimmer-dark {
  background: linear-gradient(
    90deg,
    #0F172A 0%,
    #1E293B 25%,
    #334155 50%,
    #1E293B 75%,
    #0F172A 100%
  );
  background-size: 250% 100%;
  animation: skeletonShimmer 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Image Container Skeleton Placeholder */
.img-skeleton-container {
  position: relative;
  background: linear-gradient(
    90deg,
    #F1F5F9 0%,
    #E2E8F0 25%,
    #F8FAFC 50%,
    #E2E8F0 75%,
    #F1F5F9 100%
  ) !important;
  background-size: 250% 100% !important;
  animation: skeletonShimmer 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite !important;
}

/* When image completes loading, remove shimmer seamlessly */
.img-skeleton-container.img-loaded {
  animation: none !important;
  background: transparent !important;
}

/* Smooth Progressive Image Fade-In (Prevents abrupt popping & layout jumps) */
.img-fade-in {
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity;
}

.img-fade-in.is-loaded,
#heroBgImage,
.hero-critical-img,
img[fetchpriority="high"] {
  opacity: 1 !important;
}

/* Text & Card Skeleton Placeholders */
.skeleton-line {
  height: 14px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.skeleton-title {
  height: 24px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.skeleton-card {
  border-radius: 24px;
  overflow: hidden;
}

/* Fallback Placeholder for Failed / Timed-Out Image Downloads - hidden to prevent ugly UI */
.img-fallback-card {
  display: none !important;
}

.img-fallback-card button {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 14px;
  background: #0F172A;
  color: #FFFFFF;
  border-radius: 9999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s, opacity 0.15s;
}

.img-fallback-card button:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.img-fallback-card button:active {
  transform: scale(0.97);
}

.subtle-ring {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Image rounded Apple corners */
.apple-img {
  border-radius: 28px;
  overflow: hidden;
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.28);
}

/* Vertical Moving Photo Showcase Marquee */
@keyframes verticalMarqueeUp {
  0% {
    transform: translateY(0%);
  }
  100% {
    transform: translateY(-50%);
  }
}

@keyframes verticalMarqueeDown {
  0% {
    transform: translateY(-50%);
  }
  100% {
    transform: translateY(0%);
  }
}

.animate-vertical-up {
  animation: verticalMarqueeUp 28s linear infinite;
}

.animate-vertical-down {
  animation: verticalMarqueeDown 28s linear infinite;
}

.animate-vertical-up:hover,
.animate-vertical-down:hover,
.vertical-marquee-container:hover .animate-vertical-up,
.vertical-marquee-container:hover .animate-vertical-down {
  animation-play-state: paused;
}

/* Horizontal Moving Photo Showcase Marquee (Infinite Seamless Loop) */
@keyframes horizontalMarqueeLeft {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

@keyframes horizontalMarqueeRight {
  0% {
    transform: translateX(-50%);
  }
  100% {
    transform: translateX(0);
  }
}

.animate-marquee-left {
  display: flex;
  width: max-content;
  animation: horizontalMarqueeLeft 38s linear infinite;
  will-change: transform;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.animate-marquee-right {
  display: flex;
  width: max-content;
  animation: horizontalMarqueeRight 38s linear infinite;
  will-change: transform;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.animate-marquee-left:hover,
.animate-marquee-right:hover,
.animate-marquee-left:active,
.animate-marquee-right:active,
.horizontal-marquee-container:hover .animate-marquee-left,
.horizontal-marquee-container:hover .animate-marquee-right,
.horizontal-marquee-container:active .animate-marquee-left,
.horizontal-marquee-container:active .animate-marquee-right {
  animation-play-state: paused;
}

/* Touch responsiveness & compact card sizing on small screens */
@media (max-width: 640px) {
  .horizontal-marquee-container .animate-marquee-left > div,
  .horizontal-marquee-container .animate-marquee-right > div {
    width: 220px !important;
    border-radius: 18px !important;
  }
}

/* Hide scrollbar utility for sleek horizontal mobile pill sliders */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Fast Rendering Optimization for Off-Screen Sections */
footer {
  content-visibility: auto;
  contain-intrinsic-size: 1px 450px;
}

/* ==========================================================================
   OFFLINE & ZERO-CDN RESILIENCE FALLBACK UTILITIES
   Ensures the entire UI, header, hero, grid, and navigation remain 100%
   perfect even if external CDNs are delayed, offline, or blocked.
   ========================================================================== */

/* Universal Display Helpers */
.hidden, [hidden] {
  display: none !important;
}

/* Modals & Overlays - Never show in normal flow */
#mobileMenuOverlay,
#storyVideoModal,
#constitutionModal,
#adminPinModal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
}
#mobileMenuOverlay.hidden,
#storyVideoModal.hidden,
#constitutionModal.hidden,
#adminPinModal.hidden {
  display: none !important;
}

/* Critical Header & Navigation Fallbacks */
#mainHeader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 5rem;
  z-index: 50;
  display: flex;
  align-items: center;
}

#mainHeader > div {
  width: 100%;
  max-width: 80rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Hero Section Structural Positioning */
#section-hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  overflow: hidden;
  width: 100%;
}

#section-hero .absolute.inset-0,
#section-hero > div:first-child {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

#heroBgImage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  z-index: 1;
}

#heroVideoPc,
#heroVideoMobile {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  z-index: 2;
  background-color: transparent;
}

@media (max-width: 767px) {
  #heroVideoPc {
    display: none !important;
  }
  #heroVideoMobile {
    display: block !important;
  }
}

@media (min-width: 768px) {
  #heroVideoPc {
    display: block !important;
  }
  #heroVideoMobile {
    display: none !important;
  }
}

/* Essential Responsive Helpers */
@media (max-width: 1023px) {
  .lg\:flex {
    display: none !important;
  }
  .lg\:hidden {
    display: flex !important;
  }
}

@media (min-width: 1024px) {
  .hidden.lg\:flex,
  .lg\:flex {
    display: flex !important;
  }
  .lg\:hidden {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .md\:flex {
    display: none !important;
  }
  .md\:block {
    display: none !important;
  }
  .md\:grid {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .md\:hidden {
    display: none !important;
  }
  .md\:flex {
    display: flex !important;
  }
  .md\:block {
    display: block !important;
  }
  .md\:grid {
    display: grid !important;
  }
}

@media (max-width: 639px) {
  .sm\:flex {
    display: none !important;
  }
  .sm\:block {
    display: none !important;
  }
}

@media (min-width: 640px) {
  .sm\:hidden {
    display: none !important;
  }
  .sm\:flex {
    display: flex !important;
  }
  .sm\:block {
    display: block !important;
  }
}

/* Base Layout & Flexbox */
.fixed { position: fixed !important; }
.absolute { position: absolute !important; }
.relative { position: relative !important; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0 !important; }
.left-0 { left: 0 !important; }
.right-0 { right: 0 !important; }
.bottom-0 { bottom: 0 !important; }
.bottom-4 { bottom: 1rem !important; }
.left-4 { left: 1rem !important; }
.right-4 { right: 1rem !important; }
.z-50 { z-index: 50 !important; }
.z-40 { z-index: 40 !important; }
.z-10 { z-index: 10 !important; }
.-z-10 { z-index: -10 !important; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.h-20 { height: 5rem; }
.max-w-7xl { max-width: 80rem; margin-left: auto; margin-right: auto; }
.max-w-3xl { max-width: 48rem; }
.max-w-xl { max-width: 36rem; }
.max-w-sm { max-width: 24rem; }
.rounded-full { border-radius: 9999px; }
.rounded-2xl { border-radius: 1rem; }
.rounded-3xl { border-radius: 1.5rem; }
.overflow-hidden { overflow: hidden; }

/* Grid fallbacks */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
@media (min-width: 640px) {
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lg\:grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .lg\:col-span-2 { grid-column: span 2 / span 2; }
  .lg\:col-span-3 { grid-column: span 3 / span 3; }
  .lg\:col-span-4 { grid-column: span 4 / span 4; }
  .lg\:col-span-5 { grid-column: span 5 / span 5; }
  .lg\:col-span-7 { grid-column: span 7 / span 7; }
  .lg\:col-span-8 { grid-column: span 8 / span 8; }
  .lg\:col-span-9 { grid-column: span 9 / span 9; }
}
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }
.gap-10 { gap: 2.5rem; }
