/* Mobile/H5 responsive overrides.
   Keep existing scroll effects, pinned sections, and canvas animations. */

:root {
  /* JS sets this to window.innerHeight * 0.01 to avoid iOS 100vh issues */
  --vh: 1vh;
}

html,
body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Use dynamic viewport height on mobile browsers (especially iOS Safari). */
@media (max-width: 56.25em) {
  body,
  #main {
    overflow-x: hidden;
  }

  #main {
    overflow: visible;
  }

  /* Persistent top navbar on mobile */
  .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 100000;
    background: rgba(17, 55, 202, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .navbar__navItems {
    position: fixed;
    left: 0;
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  }

  #page1,
  #page2,
  #page3,
  #page4,
  #page5,
  #page6,
  #page7,
  #page8,
  #page9,
  #page10,
  #page11,
  #page12,
  #page13 {
    scroll-margin-top: calc(5rem + env(safe-area-inset-top) + 0.75rem);
  }

  #page1,
  #page2,
  #page3,
  #page4,
  #page5,
  #page6,
  #page7,
  #page8,
  #page9,
  #page10,
  #page11,
  #page12,
  #page13 {
    height: calc(var(--vh, 1vh) * 100);
    width: 100%;
  }

  #page9,
  #page10,
  #page11,
  #page13 {
    height: auto;
    min-height: calc(var(--vh, 1vh) * 100);
  }

  #page12 {
    height: auto;
    min-height: calc(var(--vh, 1vh) * 80);
  }

  /* Prefer stable viewport units when supported (prevents iOS URL bar resize jump). */
  @supports (height: 100svh) {
    #page1,
    #page2,
    #page3,
    #page4,
    #page5,
    #page6,
    #page7,
    #page8 {
      height: 100svh;
    }

    #page9,
    #page10,
    #page11,
    #page12,
    #page13 {
      height: auto;
      min-height: 100svh;
    }

    #page12 {
      min-height: 80svh;
    }

    .navbar__navItems {
      height: 100svh;
    }
  }

  /* Slightly tighter spacing for H5 */
  .container {
    width: 92%;
    padding-block: 4.5rem;
  }

  .textAnimation {
    width: 92%;
    padding-top: 6.5rem;
  }

  body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui,
      sans-serif;
  }

  /* Safe area */
  .navbar {
    padding-top: env(safe-area-inset-top);
  }

  .navbar__navItems {
    height: calc(var(--vh, 1vh) * 100);
    padding-top: calc(5rem + env(safe-area-inset-top));
  }

  .navbar__navItems .nav-items {
    font-size: clamp(1.25rem, 6.5vw, 2rem);
    margin-bottom: 1.5rem;
  }

  .navbar__navItems .social-links {
    margin-top: auto;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.875rem;
  }

  /* Hero layout */
  .hero {
    left: 5%;
    width: 90%;
  }

  .hero__subText-CTA {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }

  .hero__subText {
    width: 100%;
    margin-bottom: 0;
    line-height: 1.5;
  }

  .hero__mainText {
    line-height: 1.05;
    font-size: clamp(2rem, 9vw, 3rem);
  }

  /* Page8 title block */
  .textContainer {
    bottom: 14%;
    width: 90%;
  }

  /* Page10: show roadmap canvas on mobile (was hidden in the original clone). */
  #page10 .creation__grid {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
  }

  #page10 .creation__grid .grid__right {
    display: flex !important;
    visibility: visible !important;
    align-items: center;
    justify-content: center;
  }

  #page10 .creation__grid .grid__right .roadmap__canvas {
    visibility: visible !important;
    width: min(92vw, 520px);
    height: auto;
    max-width: 100%;
    aspect-ratio: 1 / 1;
  }

  /* Put canvas first for a more "H5" flow */
  #page10 .creation__grid .grid__right {
    order: 1;
  }
  #page10 .creation__grid .grid__left {
    order: 2;
  }

  /* Tighten page10 timeline typography for small screens */
  #page10 .creation__grid .grid__left .roadmap__items {
    padding-left: 2.75rem;
    gap: 1.5rem;
  }

  #page10 .creation__grid .grid__left .roadmap__items picture {
    display: none;
  }

  #page10 .creation__grid .grid__left .roadmap__items .info {
    width: 100%;
  }

  #page10 .creation__grid .grid__left .roadmap__items .info__title h2 {
    width: 100%;
    font-size: clamp(1.25rem, 6.5vw, 1.75rem);
  }

  #page10 .creation__grid .grid__left .roadmap__items .info__text {
    font-size: 1rem;
  }

  /* Page9 */
  .whatInfo {
    gap: 2rem;
  }

  .whatInfo__title {
    width: 100%;
  }

  .whatInfo__info {
    gap: 2rem;
  }

  .whatInfo__subInfo p {
    font-size: 1rem;
    line-height: 1.6;
  }

  /* Page11 */
  .blog__title {
    margin-bottom: 3.5rem;
  }

  .blog__items .item .item__image {
    height: 11.5rem;
    border-radius: 1.25rem;
  }

  /* Footer */
  .footer {
    padding-block: 4.5rem;
  }

  .footer__part2 li {
    padding-inline: 1.25rem;
  }

  .footer__part3 {
    padding-inline: 1.25rem;
  }
}
