/*
 * Mobile native polish for public pages.
 * Keeps navbar at the top and improves phone ergonomics/safe-area behavior.
 * Page-specific layout decisions should stay in page-level CSS files.
 */

@media (max-width: 991px) {
  body:is(.public-mood, .is-home) {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-tap-highlight-color: transparent;
  }

  body:is(.public-mood, .is-home) .container {
    max-width: 100%;
    width: 100%;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  body:is(.public-mood, .is-home) .navbar {
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom-color: rgba(var(--primary-rgb), 0.24);
  }

  body:is(.public-mood, .is-home) .navbar .container {
    min-height: calc(58px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  body:is(.public-mood, .is-home) .nav-utility-actions .theme-toggle-btn,
  body:is(.public-mood, .is-home) .nav-utility-actions .nav-icon-btn,
  body:is(.public-mood, .is-home) .navbar-toggler {
    min-width: 42px;
    min-height: 42px;
  }

  body:is(.public-mood, .is-home) .main-content {
    padding-top: calc(72px + env(safe-area-inset-top));
  }

  body:is(.public-mood, .is-home) .offcanvas-backdrop.show {
    background: rgba(5, 12, 28, 0.56);
  }
}

@media (max-width: 767px) {
  body:is(.public-mood, .is-home) {
    --section-padding: 48px;
    --app-fs-title-lg: clamp(1.44rem, 6vw, 1.72rem);
    --app-fs-title-md: clamp(1.18rem, 4.9vw, 1.34rem);
    --app-fs-title-sm: clamp(1.02rem, 4.2vw, 1.16rem);
    --app-fs-body: 0.9rem;
    --app-fs-meta: 0.76rem;
    --app-lh-body: 1.52;
    --app-ls-tight: -0.012em;
    --app-ls-meta: 0.045em;
    padding-bottom: env(safe-area-inset-bottom);
    background-image:
      radial-gradient(1200px 520px at 0% -10%, rgba(var(--primary-rgb), 0.12), transparent 70%),
      radial-gradient(900px 520px at 100% -24%, rgba(var(--secondary-rgb), 0.11), transparent 74%);
    background-attachment: fixed;
    font-size: 15px;
    line-height: var(--app-lh-body);
    letter-spacing: 0.002em;
  }

  body:is(.public-mood, .is-home) :is(.page-title, .section-title) {
    letter-spacing: var(--app-ls-tight);
  }

  body:is(.public-mood, .is-home) .page-title {
    font-size: var(--app-fs-title-lg);
    line-height: 1.12;
  }

  body:is(.public-mood, .is-home) .page-subtitle {
    font-size: var(--app-fs-body);
    line-height: var(--app-lh-body);
  }

  body:is(.public-mood, .is-home) .section-subtitle {
    font-size: 0.7rem;
    letter-spacing: var(--app-ls-meta);
    margin-bottom: 0.3rem;
  }

  body:is(.public-mood, .is-home) :is(.section-description, p, .lead) {
    line-height: var(--app-lh-body);
  }

  body:is(.public-mood, .is-home)
    :is(
      .service-title,
      .opportunity-title,
      .step-title,
      .impact-card h4,
      .author-name,
      .footer-cta-title,
      .auth-title,
      .contact-form-box h3,
      .contact-section h2
    ) {
    font-size: var(--app-fs-title-sm);
    line-height: 1.24;
    letter-spacing: -0.008em;
  }

  body:is(.public-mood, .is-home)
    :is(
      .service-description,
      .opportunity-description,
      .step-description,
      .impact-card p,
      .testimonial-text,
      .author-position,
      .contact-form-box .form-label,
      .contact-info-box,
      .auth-subtitle,
      .footer-brand-copy,
      .footer-contact li,
      .footer-links a,
      .footer-connect-list li,
      .footer-quick-links a
    ) {
    font-size: var(--app-fs-body);
    line-height: var(--app-lh-body);
    letter-spacing: 0.002em;
  }

  body:is(.public-mood, .is-home)
    :is(
      .opportunity-kicker,
      .impact-label,
      .stat-label,
      .opportunity-meta,
      .footer-heading,
      .footer-copyright,
      .breadcrumb,
      .breadcrumb-item,
      .form-text,
      small
    ) {
    font-size: var(--app-fs-meta);
    letter-spacing: 0.03em;
  }

  body:is(.public-mood, .is-home)
    :is(.btn, .mobile-quick-action, .footer-legal a, .footer-meta-links a) {
    font-size: 0.82rem;
    letter-spacing: 0.03em;
  }

  body:is(.public-mood, .is-home)
    :is(
      .service-card,
      .opportunity-card,
      .testimonial-card,
      .impact-card,
      .home-empty-state,
      .contact-form-box,
      .contact-info-box,
      .auth-panel,
      .auth-intro,
      .opportunity-grid-card,
      .event-grid-card,
      .community-stat-card,
      .services-stat-card,
      .impact-stat-card,
      .opportunity-stat-card
    ) {
    padding: 0.96rem;
  }

  body:is(.public-mood, .is-home)
    :is(
      .service-features li,
      .opportunity-meta span,
      .testimonial-stars,
      .impact-stat-item .impact-label
    ) {
    margin-bottom: 0.26rem;
  }

  body:is(.public-mood, .is-home) .page-header {
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    box-shadow: 0 18px 36px rgba(3, 8, 20, 0.26);
    padding-top: clamp(24px, 10vw, 34px);
    padding-bottom: clamp(42px, 10vw, 58px);
    overflow: clip;
  }

  body:is(.public-mood, .is-home)
    main
    > section:not(.hero-section):not(.footer-section):not(.page-header),
  body:is(.public-mood, .is-home) > section:not(.page-header):not(.footer-section):not(.footer) {
    margin: 0 8px 12px;
    border-radius: 20px;
    border: 1px solid rgba(var(--primary-rgb), 0.18);
    box-shadow: 0 14px 28px rgba(3, 8, 20, 0.18);
    overflow: clip;
  }

  :root[data-theme='dark']
    body:is(.public-mood, .is-home)
    main
    > section:not(.hero-section):not(.footer-section):not(.page-header),
  :root[data-theme='dark']
    body:is(.public-mood, .is-home)
    > section:not(.page-header):not(.footer-section):not(.footer) {
    background: rgba(var(--dark-base-2-rgb), 0.72);
  }

  :root[data-theme='light']
    body:is(.public-mood, .is-home)
    main
    > section:not(.hero-section):not(.footer-section):not(.page-header),
  :root[data-theme='light']
    body:is(.public-mood, .is-home)
    > section:not(.page-header):not(.footer-section):not(.footer) {
    background: rgba(255, 252, 248, 0.92);
    border-color: rgba(82, 64, 58, 0.14);
    box-shadow: 0 14px 28px rgba(82, 64, 58, 0.14);
  }

  body:is(.public-mood, .is-home)
    :is(
      .contact-form-box,
      .contact-info-box,
      .auth-panel,
      .auth-intro,
      .service-card,
      .service-grid-card,
      .services-process-card,
      .impact-card,
      .impact-project-card,
      .opportunity-grid-card,
      .event-grid-card,
      .project-card,
      .product-card,
      .testimonial-card,
      .home-empty-state,
      .community-stat-card,
      .opportunity-stat-card,
      .services-stat-card,
      .impact-stat-card,
      .events-state-card,
      .opportunity-state-card,
      .services-state-card,
      .impact-state-card,
      .opportunity-toolbar,
      .services-toolbar,
      .community-toolbar,
      .impact-toolbar,
      .community-hero-panel,
      .impact-hero-panel,
      .opportunity-hero-panel,
      .services-hero-panel,
      .about-cta-panel,
      .about-trust-panel,
      .metric-card,
      .model-card,
      .value-card
    ) {
    border-radius: 18px;
  }

  body:is(.public-mood, .is-home) :is(.btn, .form-control, .form-select) {
    min-height: 46px;
    border-radius: 14px;
  }

  body:is(.public-mood, .is-home) textarea.form-control {
    min-height: 120px;
  }

  body:is(.public-mood, .is-home) .opportunity-toolbar-actions .btn,
  body:is(.public-mood, .is-home) .footer-cta-btn {
    width: 100%;
    justify-content: center;
  }

  body:is(.public-mood, .is-home) .footer-cta-panel {
    border-radius: 18px;
    padding: 1.1rem;
  }

  body:is(.public-mood, .is-home) .footer {
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    overflow: clip;
  }

  body:is(.public-mood, .is-home) .back-to-top {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(56px, calc(14px + env(safe-area-inset-bottom)));
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 390px) {
  body:is(.public-mood, .is-home) {
    --app-fs-title-lg: clamp(1.36rem, 6.4vw, 1.56rem);
    --app-fs-title-md: clamp(1.12rem, 5vw, 1.22rem);
    --app-fs-title-sm: clamp(0.98rem, 4.2vw, 1.08rem);
    --app-fs-body: 0.86rem;
    --app-fs-meta: 0.73rem;
  }

  body:is(.public-mood, .is-home) .container {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  body:is(.public-mood, .is-home) .page-header {
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
  }

  body:is(.public-mood, .is-home)
    main
    > section:not(.hero-section):not(.footer-section):not(.page-header),
  body:is(.public-mood, .is-home) > section:not(.page-header):not(.footer-section):not(.footer) {
    margin-left: 6px;
    margin-right: 6px;
    border-radius: 18px;
  }
}

@media (max-width: 767px) {
  .home-page {
    scroll-snap-type: none;
  }

  .home-page > section {
    scroll-snap-align: none;
    scroll-margin-top: calc(70px + env(safe-area-inset-top));
  }

  .home-page .section-header {
    margin-bottom: 1rem !important;
    text-align: left !important;
  }

  .home-page .section-header .section-title {
    font-size: clamp(1.18rem, 4.9vw, 1.34rem);
    line-height: 1.22;
    margin-bottom: 0.45rem;
  }

  .home-page .section-header .section-description {
    font-size: 0.88rem;
    line-height: 1.5;
  }

  .home-page .impact-section .section-title {
    font-size: clamp(1.24rem, 5.3vw, 1.42rem);
    line-height: 1.2;
    margin-bottom: 0.7rem !important;
  }

  .home-page [data-home-mobile-rail] {
    --bs-gutter-x: 0;
    --bs-gutter-y: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(84%, 1fr);
    gap: 12px;
    margin: 0;
    padding: 2px 2px 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .home-page [data-home-mobile-rail]::-webkit-scrollbar {
    display: none;
  }

  .home-page [data-home-mobile-rail] > [data-home-mobile-rail-item] {
    width: 100%;
    padding: 0;
    scroll-snap-align: start;
  }

  .home-mobile-rail-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.38rem;
    margin-top: 0.12rem;
    margin-bottom: 0.3rem;
    padding-inline: 0.15rem;
  }

  .home-mobile-rail-indicator[hidden] {
    display: none !important;
  }

  .home-mobile-rail-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(226, 232, 240, 0.42);
    transition:
      width 180ms var(--motion-ease-standard, ease),
      background-color 180ms var(--motion-ease-standard, ease),
      transform 140ms var(--motion-ease-standard, ease);
  }

  .home-mobile-rail-dot.is-active {
    width: 22px;
    background: rgba(var(--primary-rgb), 0.92);
    box-shadow: 0 0 0 1px rgba(var(--primary-rgb), 0.38);
  }

  .home-mobile-rail-dot:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.3);
  }

  :root[data-theme='light'] .home-mobile-rail-dot {
    background: rgba(82, 64, 58, 0.24);
  }

  :root[data-theme='light'] .home-mobile-rail-dot.is-active {
    background: rgba(var(--primary-rgb), 0.9);
    box-shadow: 0 0 0 1px rgba(var(--primary-rgb), 0.3);
  }

  .home-page :is(.service-card, .opportunity-card, .testimonial-card) {
    min-height: 100%;
    border-radius: 18px;
    padding: 1rem;
  }

  .home-page .process-timeline {
    max-width: none;
    display: grid;
    gap: 0.7rem;
  }

  .home-page .process-step {
    margin: 0 !important;
    gap: 0.82rem;
    padding: 0.8rem;
    border-radius: 16px;
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    background: rgba(var(--dark-base-2-rgb), 0.44);
  }

  .home-page .process-step::before {
    display: none !important;
  }

  .home-page .step-number {
    width: 50px;
    height: 50px;
    font-size: 1.05rem;
    box-shadow: 0 8px 16px rgba(var(--primary-rgb), 0.26);
  }

  .home-page .step-content {
    padding-top: 0.1rem;
  }

  .home-page .step-title {
    font-size: 1.02rem;
    margin-bottom: 0.4rem;
  }

  .home-page .step-description {
    font-size: 0.88rem;
    line-height: 1.5;
    margin-bottom: 0;
  }

  :root[data-theme='light'] .home-page .process-step {
    border-color: rgba(82, 64, 58, 0.15);
    background: rgba(255, 251, 246, 0.76);
  }

  .home-page .stats-section .row.g-4 {
    --bs-gutter-x: 0.58rem;
    --bs-gutter-y: 0.58rem;
  }

  .home-page .stat-box {
    min-height: 116px;
    padding: 0.86rem 0.62rem;
    border-radius: 16px;
    display: grid;
    place-content: center;
    gap: 0.2rem;
  }

  .home-page .stat-box .stat-number {
    font-size: 1.8rem;
    margin-bottom: 0;
  }

  .home-page .stat-box .stat-label {
    font-size: 0.68rem;
    letter-spacing: 0.07em;
  }

  .home-page .home-action-group {
    flex-direction: column;
    gap: 0.55rem !important;
  }

  .home-page .home-action-group .btn {
    width: 100%;
    justify-content: center;
  }

  .home-page .impact-stats {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(40%, 1fr);
    gap: 0.58rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    padding-bottom: 0.2rem;
    scrollbar-width: none;
  }

  .home-page .impact-stats::-webkit-scrollbar {
    display: none;
  }

  .home-page .impact-stat-item {
    scroll-snap-align: start;
    border-radius: 14px;
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    background: rgba(var(--dark-base-2-rgb), 0.35);
    padding: 0.72rem 0.66rem;
    min-width: 0;
  }

  :root[data-theme='light'] .home-page .impact-stat-item {
    border-color: rgba(82, 64, 58, 0.15);
    background: rgba(255, 251, 246, 0.78);
  }

  .home-page .impact-grid {
    gap: 0.72rem;
  }

  .home-page .impact-card {
    border-radius: 16px;
    padding: 1rem 0.9rem;
  }
}

@media (max-width: 390px) {
  .home-page [data-home-mobile-rail] {
    grid-auto-columns: minmax(90%, 1fr);
  }

  .home-page .section-header .section-title {
    font-size: clamp(1.12rem, 5.4vw, 1.24rem);
  }

  .home-page .impact-stats {
    grid-auto-columns: minmax(68%, 1fr);
  }
}
