/*
 * Hangsu V151 mobile responsive layer
 * Loaded after page-specific styles. Every visual override is restricted to
 * viewports below 1024px so the V148 desktop layout remains unchanged.
 */

:root {
  --mobile-gutter: clamp(1rem, 4vw, 1.5rem);
  --mobile-nav-height: 4.25rem;
}

@media (max-width: 1023px) {
  html {
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
  }

  img,
  picture,
  video,
  canvas,
  iframe {
    max-width: 100%;
  }

  button,
  input,
  select,
  textarea {
    max-width: 100%;
    font: inherit;
  }

  [id] {
    scroll-margin-top: 7rem;
  }

  :where(main, section, header, footer, nav, article, aside, div) {
    min-width: 0;
  }

  :where(h1, h2, h3, h4, p, li, dd, a, span) {
    overflow-wrap: break-word;
  }

  :where(
    .container,
    .container-wide,
    .section-inner,
    .course-nav-container,
    .course-detail-wrap,
    .caac-wrap,
    .defense-wrap,
    .article-shell,
    .footer-top-content,
    .footer-main,
    .footer-bottom-content
  ) {
    width: min(100% - 2 * var(--mobile-gutter), 100%);
    max-width: none;
    margin-inline: auto;
    padding-inline: 0;
  }

  .navbar-top,
  .navbar.scrolled .navbar-top,
  .navbar-bottom,
  .navbar.scrolled .navbar-bottom {
    padding-inline: var(--mobile-gutter);
  }

  .section,
  :where(
    .student-gallery-section,
    .course-nav-section,
    .course-compare-section,
    .testimonials-section,
    .faq-section,
    .career-section,
    .about-intro,
    .about-timeline
  ) {
    padding-block: clamp(3.5rem, 8vw, 5rem);
  }

  :where(.industry-hero-grid, .about-hero-wrapper, .intro-grid) {
    gap: clamp(2rem, 5vw, 3.5rem);
  }
}

@media (max-width: 767px) {
  :root {
    --mobile-gutter: 1rem;
  }

  body {
    font-size: 1rem;
  }

  :where(h1, h2, h3, p) {
    max-width: 100%;
  }

  :where(.section-title, .course-nav-title) {
    font-size: clamp(1.75rem, 8vw, 2.25rem);
    line-height: 1.2;
    text-wrap: balance;
  }

  .section-subtitle {
    font-size: 1.05rem;
    line-height: 1.5;
  }

  .section-description {
    font-size: 0.98rem;
    line-height: 1.75;
  }

  /* Navigation */
  .navbar {
    width: 100%;
  }

  .navbar.mobile-open,
  .navbar.mobile-open .navbar-top {
    background: rgba(10, 22, 40, 0.98);
  }

  .navbar-top,
  .navbar.scrolled .navbar-top {
    min-height: calc(var(--mobile-nav-height) + env(safe-area-inset-top));
    padding: max(0.5rem, env(safe-area-inset-top)) var(--mobile-gutter) 0.5rem;
  }

  .nav-brand,
  .logo-new {
    min-width: 0;
    max-width: calc(100vw - 5rem);
  }

  .logo-new {
    gap: 0.5rem;
  }

  .logo-img,
  .navbar.scrolled .logo-img {
    width: 3rem;
    height: 2.5rem;
    flex: 0 0 3rem;
    transform: none;
  }

  .logo-text {
    min-width: 0;
  }

  .logo-title,
  .navbar.scrolled .logo-title {
    max-width: 13.5rem;
    overflow: hidden;
    font-size: clamp(0.82rem, 3.7vw, 1rem);
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .logo-subtitle,
  .navbar.scrolled .logo-subtitle,
  .nav-divider,
  .nav-slogan {
    display: none;
  }

  .mobile-menu-toggle {
    min-width: 44px;
    min-height: 44px;
    margin-left: auto;
  }

  .navbar-bottom,
  .navbar.scrolled .navbar-bottom {
    max-height: calc(100dvh - var(--mobile-nav-height) - env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .navbar .nav-link,
  .navbar .dropdown-item {
    min-height: 44px;
    white-space: normal;
  }

  .navbar .nav-link {
    padding: 0.75rem 0.875rem;
    font-size: 1rem;
  }

  .navbar.mobile-open .dropdown-menu {
    margin-left: 0.75rem;
    padding-left: 0.5rem;
  }

  .navbar.mobile-open .dropdown-item {
    padding: 0.7rem 0.75rem;
  }

  /* Homepage hero */
  .hero {
    min-height: max(42rem, 100svh);
  }

  .hero-slide-content {
    inset: calc(var(--mobile-nav-height) + env(safe-area-inset-top)) 0 9.25rem;
    justify-content: center;
    padding-inline: var(--mobile-gutter);
  }

  .hero-subtitle {
    margin-bottom: 0.8rem;
    font-size: 0.72rem;
    line-height: 1.5;
    letter-spacing: 0.12em;
  }

  .hero-title,
  .hero-title--split {
    margin-bottom: 1rem;
    font-size: clamp(1.85rem, 9vw, 2.75rem);
    line-height: 1.15;
    text-wrap: balance;
  }

  .hero-title-line {
    white-space: normal;
  }

  .hero-description {
    margin-bottom: 1.4rem;
    font-size: 0.98rem;
    line-height: 1.7;
  }

  .hero-cta,
  :where(.courses-hero-cta, .coop-hero-actions, .training-hero-cta, .eco-hero-cta, .defense-hero-actions) {
    display: grid;
    grid-template-columns: 1fr;
    width: min(100%, 22rem);
    gap: 0.75rem;
    margin-inline: auto;
  }

  .hero-cta .btn,
  :where(.courses-hero-cta, .coop-hero-actions, .training-hero-cta, .eco-hero-cta, .defense-hero-actions) :where(a, button) {
    width: 100%;
    min-height: 46px;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
  }

  .hero-controls {
    bottom: calc(6.6rem + env(safe-area-inset-bottom));
    gap: 0.4rem;
  }

  .hero-arrow {
    width: 44px;
    height: 44px;
  }

  .hero-dot {
    width: 2rem;
    height: 44px;
    background-clip: content-box;
    padding-block: 20px;
  }

  .hero-dot.active {
    background-clip: content-box;
  }

  .hero-highlights {
    padding: 0.85rem var(--mobile-gutter) max(0.85rem, env(safe-area-inset-bottom));
  }

  .hero-highlights-inner {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem 0.9rem;
  }

  .hero-highlight {
    gap: 0.45rem;
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .hero-highlight svg {
    width: 1.1rem;
    height: 1.1rem;
    flex: 0 0 1.1rem;
  }

  /* Other page heroes */
  :where(.courses-hero, .news-hero, .about-hero, .coop-hero, .industry-hero, .training-hero, .eco-hero, .base-hero) {
    min-height: auto;
    height: auto;
    padding-top: calc(var(--mobile-nav-height) + env(safe-area-inset-top) + 2.5rem);
    padding-bottom: 3.5rem;
  }

  :where(.courses-hero-content, .news-hero-content, .about-hero-content, .coop-hero-content, .industry-hero-content, .training-hero-content, .eco-hero-content, .base-hero-content) {
    width: 100%;
    max-width: none;
    padding: 0 var(--mobile-gutter);
  }

  :where(.courses-hero-title, .news-hero-title, .about-hero-title, .coop-hero-title, .industry-hero-title, .training-hero-title, .eco-hero-title, .base-hero-title) {
    font-size: clamp(2rem, 10vw, 3rem);
    line-height: 1.15;
    text-wrap: balance;
  }

  :where(.courses-hero-desc, .news-hero-subtitle, .about-hero-desc, .coop-hero-desc, .industry-hero-desc, .training-hero-desc, .eco-hero-desc, .base-hero-desc) {
    font-size: 1rem;
    line-height: 1.75;
  }

  .courses-hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-bottom: 0;
  }

  .courses-hero-highlights {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    margin-top: 2.5rem;
    gap: 0;
    padding: 1rem var(--mobile-gutter) max(1rem, env(safe-area-inset-bottom));
    background: rgba(7, 18, 34, 0.68);
  }

  .courses-highlight {
    justify-content: flex-start;
    padding: 0.75rem;
  }

  :where(.about-hero-wrapper, .industry-hero-grid) {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    padding-inline: var(--mobile-gutter);
  }

  .about-hero-content {
    padding: 0;
    text-align: center;
  }

  .about-hero-image img {
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
  }

  :where(.about-hero-stats, .industry-hero-stats, .training-hero-stats, .base-hero-floating-stats, .coop-hero-stats) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 0.75rem;
    padding-inline: 0;
  }

  :where(.hero-stat, .industry-hero-stat, .training-stat, .base-hero-floating-stat, .coop-hero-stat) {
    min-width: 0;
    padding: 1rem;
  }

  /* Grids and cards */
  :where(
    .courses-grid,
    .gallery-grid,
    .featured-grid,
    .news-grid,
    .intro-grid,
    .capability-grid,
    .coop-directions-grid,
    .process-grid,
    .testimonials-grid,
    .faq-grid,
    .career-grid,
    .base-equipment-grid,
    .support-cards,
    .value-image-grid,
    .culture-grid,
    .chess-grid,
    .global-grid
  ) {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  :where(.features-grid, .guarantees-grid, .stats-grid, .support-stats, .benefits-stats, .consult-stats, .global-stats, .media-logos-grid, .partners-grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  :where(.course-card, .featured-main, .featured-card, .news-card, .testimonial-card, .career-card, .faq-item) {
    min-width: 0;
  }

  .course-card {
    min-height: 28rem;
  }

  .featured-main,
  .featured-card {
    min-height: 22rem;
  }

  .featured-main-content,
  .featured-card-content,
  .news-card-content {
    padding: 1.25rem;
  }

  .featured-title {
    font-size: 1.35rem;
  }

  /* Course list and course details */
  .course-nav-section,
  .student-gallery-section,
  .course-compare-section {
    padding-block: 3.5rem;
  }

  .course-tabs-wrapper {
    overflow: hidden;
  }

  .course-tabs {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0.25rem 0 0.75rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .course-tab {
    flex: 0 0 auto;
    min-width: 8.5rem;
    min-height: 48px;
    padding: 0.75rem;
    scroll-snap-align: start;
  }

  .course-tab .tab-name {
    display: inline;
  }

  .course-preview-panels {
    padding: 1rem;
  }

  .preview-panel,
  .course-hero-layout,
  .course-section-grid,
  .course-contact-layout,
  .caac-hero-grid,
  .caac-contact-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-content,
  .course-section-card,
  .caac-contact-form {
    padding: 1.25rem;
  }

  .course-detail-hero,
  .caac-hero {
    padding-top: calc(var(--mobile-nav-height) + env(safe-area-inset-top) + 2.75rem);
    padding-bottom: 3.5rem;
  }

  .course-hero-copy h1,
  .caac-hero-copy h1 {
    font-size: clamp(2rem, 10vw, 3rem);
    line-height: 1.12;
  }

  .course-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .course-facts div {
    min-width: 0;
  }

  :where(.course-button-row, .caac-hero-actions, .preview-buttons) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  :where(.course-button-row, .caac-hero-actions, .preview-buttons) :where(a, button) {
    width: 100%;
    min-height: 46px;
  }

  .course-form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Timelines become a readable vertical card list on phones. */
  .timeline-scroll,
  .timeline-scroll-wrapper {
    overflow: visible;
    padding-inline: var(--mobile-gutter);
  }

  .timeline-content,
  .timeline-projects {
    min-width: 0;
    width: 100%;
  }

  .timeline-content {
    padding: 0;
  }

  .timeline-projects {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .timeline-svg,
  .timeline-project-line {
    display: none;
  }

  .timeline-project,
  .timeline-project:nth-child(odd),
  .timeline-project:nth-child(even) {
    display: grid;
    grid-template-columns: 4.5rem minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    margin: 0;
  }

  .timeline-year,
  .timeline-project:nth-child(odd) .timeline-year,
  .timeline-project:nth-child(even) .timeline-year {
    position: static;
    transform: none;
    white-space: normal;
  }

  .timeline-card {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  /* Tables remain intact and can be swiped horizontally. */
  :where(.compare-table-wrapper, .table-wrapper, .course-table-wrapper) {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  :where(.compare-table-wrapper, .table-wrapper, .course-table-wrapper)::after {
    content: "左右滑动查看完整表格";
    display: block;
    padding: 0.65rem 0.25rem 0;
    color: #64748b;
    font-size: 0.75rem;
    text-align: center;
  }

  .compare-header,
  .compare-row {
    min-width: 34rem;
  }

  /* Forms and modal */
  :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    min-height: 46px;
    font-size: 16px;
  }

  .modal {
    height: 100dvh;
    align-items: flex-end;
    padding: max(0.75rem, env(safe-area-inset-top)) var(--mobile-gutter) max(0.75rem, env(safe-area-inset-bottom));
  }

  .modal-content {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 1rem 1rem 0.75rem 0.75rem;
    overscroll-behavior: contain;
  }

  .modal-header {
    padding: 1.5rem 3.5rem 1.1rem 1.25rem;
    text-align: left;
  }

  .modal-title {
    font-size: 1.35rem;
  }

  .modal-subtitle {
    font-size: 0.88rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-close {
    top: 0.75rem;
    right: 0.75rem;
    width: 44px;
    height: 44px;
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
  }

  .contact-info,
  .checkbox-group {
    grid-template-columns: minmax(0, 1fr);
  }

  .contact-item {
    white-space: normal;
    overflow: visible;
  }

  .form-section,
  .cta-form-card,
  .enroll-card {
    padding: 1rem;
  }

  /* Article and footer */
  .article-shell {
    width: calc(100% - 2 * var(--mobile-gutter));
  }

  .article-hero {
    padding: calc(var(--mobile-nav-height) + env(safe-area-inset-top) + 2.5rem) 0 2rem;
  }

  .article-title {
    font-size: clamp(1.85rem, 9vw, 2.6rem);
    line-height: 1.2;
  }

  .article-main {
    padding-block: 2rem 3.5rem;
  }

  .article-body {
    font-size: 1rem;
    line-height: 1.85;
  }

  .article-related-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-top-content,
  .footer-bottom-content,
  .footer-brand-horizontal,
  .footer-top-phone {
    align-items: flex-start;
  }

  .footer-top-content,
  .footer-bottom-content {
    flex-direction: column;
  }

  .footer-brand-horizontal img {
    width: 4.25rem;
    height: auto;
  }

  .footer-top-phone {
    font-size: 1.25rem;
  }

  .footer-columns,
  .footer-grid,
  .footer-content {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.75rem;
  }

  .footer-brand {
    grid-column: auto;
  }

  .footer-bottom-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem 1.25rem;
  }

  :where(.float-contact, .floating-cta) {
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .floating-btn {
    min-width: 48px;
    min-height: 48px;
    padding: 0.75rem 1rem;
  }
}

@media (max-width: 420px) {
  .logo-title,
  .navbar.scrolled .logo-title {
    max-width: 11.5rem;
    font-size: 0.8rem;
  }

  .hero-highlights-inner,
  :where(.about-hero-stats, .industry-hero-stats, .training-hero-stats, .base-hero-floating-stats, .coop-hero-stats),
  :where(.features-grid, .guarantees-grid, .stats-grid, .support-stats, .benefits-stats, .consult-stats, .global-stats, .media-logos-grid, .partners-grid),
  .cta-benefits,
  .course-facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .courses-hero-highlights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero {
    min-height: 46rem;
  }

  .hero-slide-content {
    inset: calc(var(--mobile-nav-height) + env(safe-area-inset-top)) 0 11.5rem;
  }

  .course-card {
    min-height: 26rem;
  }

  .timeline-project {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1023px) and (hover: none),
       (max-width: 1023px) and (pointer: coarse) {
  :where(
    .course-card,
    .gallery-item,
    .timeline-card,
    .testimonial-card,
    .career-card,
    .featured-main,
    .featured-card,
    .news-card,
    .floating-btn,
    .float-btn
  ):hover {
    transform: none;
  }
}

@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
