/* H5 mobile layer — loaded after styles.css */

:root {
  --h5-tab-h: 56px;
  --h5-safe-b: env(safe-area-inset-bottom, 0px);
  --h5-safe-t: env(safe-area-inset-top, 0px);
}

@media (max-width: 960px) {
  body {
    padding-bottom: calc(var(--h5-tab-h) + var(--h5-safe-b) + 8px);
    -webkit-tap-highlight-color: transparent;
  }

  body.menu-open,
  body.filter-open {
    overflow: hidden;
  }

  .wrap {
    width: min(calc(100% - 32px), var(--max));
  }

  /* topbar compact */
  .topbar {
    font-size: 11px;
    padding: 6px 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-row {
    min-height: 56px;
  }

  .logo {
    font-size: 18px;
  }

  .logo-mark-img {
    width: 34px;
    height: 34px;
  }

  /* mobile menu overlay + panel */
  .nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(5, 16, 12, 0.45);
    backdrop-filter: blur(2px);
  }

  .nav-overlay.open {
    display: block;
  }

  .mobile-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    top: calc(56px + var(--h5-safe-t) + 28px);
    z-index: 46;
    margin: 0;
    padding: 12px 16px calc(16px + var(--h5-safe-b));
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 32px rgba(16, 35, 26, 0.12);
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-nav.open {
    display: grid;
    gap: 4px;
  }

  .mobile-nav a {
    padding: 14px 12px;
    font-size: 15px;
    border-radius: 10px;
  }

  .mobile-nav a.on {
    background: #e8f6ee;
    color: var(--green-2);
  }

  .mobile-nav-call {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
  }

  .mobile-nav-call a {
    text-align: center;
    background: var(--green);
    color: #fff !important;
    font-weight: 700;
  }

  .menu-btn[aria-expanded="true"] {
    border-color: var(--green);
    background: #e8f6ee;
  }

  /* hero mobile */
  .hero {
    min-height: 72vh;
  }

  .hero-inner {
    padding: 72px 0 88px;
  }

  .hero-brand {
    font-size: clamp(40px, 12vw, 64px);
  }

  .hero h1 {
    font-size: clamp(22px, 5.5vw, 30px);
  }

  .hero p {
    font-size: 15px;
  }

  .hero-actions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 6px);
    padding: 0 14px;
    font-size: 13px;
  }

  .hero-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .hero-metrics strong {
    font-size: 17px;
  }

  .hero-nav {
    bottom: 12px;
  }

  .hero-arrows {
    display: none;
  }

  /* page sections */
  .page-top {
    padding: 32px 0 20px;
  }

  .section {
    padding: 40px 0;
  }

  .cases-hero-inner {
    padding: 32px 0 28px;
  }

  .case-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }

  /* hide desktop sidebar on mobile — use drawer */
  .cases-side {
    display: none;
  }

  .cases-side.is-drawer-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 80;
    top: 0;
    padding: calc(12px + var(--h5-safe-t)) 16px calc(var(--h5-tab-h) + var(--h5-safe-b) + 16px);
    background: rgba(243, 247, 244, 0.98);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .filter-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    position: sticky;
    top: 0;
    background: rgba(243, 247, 244, 0.98);
    padding-bottom: 8px;
    z-index: 1;
  }

  .filter-drawer-head h3 {
    font-size: 18px;
    margin: 0;
  }

  .filter-drawer-close {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .h5-filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }

  .h5-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
  }

  .h5-filter-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
  }

  /* horizontal chip scroll */
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin-left: -4px;
    margin-right: -4px;
    padding-left: 4px;
    padding-right: 4px;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .filters .chip {
    flex-shrink: 0;
  }

  .cases-toolbar {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }

  .cases-toolbar h2 {
    font-size: 20px;
  }

  /* cards */
  .grid-3 {
    gap: 12px;
  }

  .case-rich .body {
    padding: 14px 16px 16px;
  }

  .case-rich h3 {
    font-size: 16px;
  }

  .featured-row {
    gap: 14px;
  }

  .case-feature-card .body {
    padding: 16px;
  }

  /* pager touch friendly */
  .pager a {
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* contact form */
  .contact-grid {
    gap: 16px;
  }

  .box {
    padding: 20px;
  }

  .form-row input,
  .form-row select,
  .form-row textarea {
    font-size: 16px; /* prevent iOS zoom */
  }

  /* footer compact */
  .site-footer {
    padding: 40px 0 20px;
  }

  .footer-grid {
    gap: 20px;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  /* bottom tab bar */
  .h5-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: var(--h5-tab-h);
    padding-bottom: var(--h5-safe-b);
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
    box-shadow: 0 -4px 24px rgba(16, 35, 26, 0.06);
  }

  .h5-tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--mute);
    line-height: 1.2;
  }

  .h5-tabbar a.on {
    color: var(--green-2);
  }

  .h5-tabbar svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .h5-tabbar a.on svg {
    stroke: var(--green);
  }

  /* floating call button */
  .h5-call-fab {
    position: fixed;
    right: 16px;
    bottom: calc(var(--h5-tab-h) + var(--h5-safe-b) + 16px);
    z-index: 55;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #07c160, #059a4c);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(7, 193, 96, 0.45);
    transition: transform 0.2s var(--ease);
  }

  .h5-call-fab:active {
    transform: scale(0.94);
  }

  .h5-call-fab svg {
    width: 24px;
    height: 24px;
    fill: #fff;
  }

  body.lightbox-open .h5-tabbar,
  body.lightbox-open .h5-call-fab {
    display: none;
  }

  .cta {
    margin-bottom: 24px;
    padding: 28px 22px;
  }

  .cta h2 {
    font-size: 22px;
  }

  .prose {
    max-width: 100%;
  }

  .prose img {
    margin-left: -4px;
    margin-right: -4px;
    width: calc(100% + 8px);
    max-width: calc(100% + 8px);
    border-radius: 10px;
  }
}

@media (max-width: 480px) {
  .wrap {
    width: min(calc(100% - 24px), var(--max));
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .stats-grid strong {
    font-size: 24px;
  }

  .sec-head h2 {
    font-size: 24px;
  }

  .h5-call-fab {
    width: 48px;
    height: 48px;
    right: 12px;
  }
}

@media (min-width: 961px) {
  .h5-tabbar,
  .h5-call-fab,
  .nav-overlay,
  .h5-filter-bar,
  .filter-drawer-head {
    display: none !important;
  }
}
