/*
  Final responsive stability layer.
  Loaded after page CSS so mobile layouts stay readable instead of collapsing
  into narrow columns, overlapping text, or drifting decorative art.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}

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



body :where(h1, h2, h3, h4, h5, h6) {
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  text-wrap: balance;
}

body :where(p, li, a, button, label, span, strong, small, td, th) {
  max-width: 100%;
  overflow-wrap: break-word;
}

body :where(img, video, iframe, canvas, svg) {
  max-width: 100%;
}

body :where(input, textarea, select, button) {
  font: inherit;
}

body :where(table) {
  border-collapse: collapse;
}

@media (max-width: 1080px) {
  body :where(
    .policy-body,
    .policy-sidebar,
    .policy-grid,
    .support-layout,
    .support-hero-layout,
    .support-meta-grid,
    .contact-hero,
    .contact-main,
    .about-hero-v2,
    .about-value-grid,
    .about-stats-v2,
    .about-team-grid,
    .category-hero,
    .category-search-card,
    .category-grid,
    .course-layout,
    .resource-grid,
    .resources-grid,
    .notes-grid,
    .notes-overview,
    .page-title-card,
    .pdf-grid,
    .pyqs-hero,
    .search-section,
    .videos-hero,
    .video-hero,
    .cards-grid,
    .video-feature-grid,
    .series-grid,
    .series-search-card,
    .hero-panel,
    .hero-layout,
    .dashboard-grid,
    .profile-grid,
    .reward-grid,
  ) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 860px) {
  body {
    -webkit-text-size-adjust: 100%;
  }

  body :where(main, .container, .wrap, .page, .shell, .support-shell-page, .policy-shell, .about-page, .about-v2, .pyqs-page, .notes-page, .testseries-body .container) {
    width: min(100%, calc(100vw - 20px)) !important;
    max-width: calc(100vw - 20px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  body :where(
    [class*="grid"],
    [class*="layout"],
    [class*="hero"],
    [class*="cards"],
    [class*="stats"],
    [class*="overview"],
    [class*="content"]
  ) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body :where(
    .hero-art,
    .policy-hero-art,
    .support-hero-visual,
    .about-hero-visual,
    .hero-visual,
    .hero-media,
    .decorative-art,
    [aria-hidden="true"].hero-art
  ) {
    max-width: 100% !important;
    transform: none !important;
  }

  body :where(.card, .section, .panel, .tile, .item, .hero-card, .support-card, .policy-card, .note-card, .pdf-card, .video-card, .about-value-card, .about-team-card, .series-card, .category-item, .stat-card, .overview-card) {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  body :where(.table-container, .admin-table-wrapper, .result-table-wrapper) {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  body :where(table, .data-table) {
    width: 100% !important;
  }

  body :where(.search-form, .search-container, .search-section, .category-search-form, .series-search-form, .support-section-head, .section-heading, .hero-actions, .action-buttons, .support-auth-actions, .support-section-actions, .modal-actions) {
    flex-wrap: wrap !important;
  }

  body :where(input, textarea, select) {
    width: 100% !important;
    max-width: 100% !important;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  body :where(main, .container, .wrap, .page, .shell, .support-shell-page, .policy-shell, .about-page, .about-v2, .pyqs-page, .notes-page) {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
  }

  body :where(.card, .section, .panel, .tile, .item, .hero-card, .support-card, .policy-card, .note-card, .pdf-card, .video-card, .about-value-card, .about-team-card, .series-card, .category-item, .stat-card, .overview-card) {
    border-radius: 12px !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  body :where(.hero, .hero-card, .policy-hero, .support-hero-card, .about-hero-v2, .pyqs-hero, .page-title-card, .series-hero, .hero-panel) {
    min-height: 0 !important;
    padding: 20px 16px !important;
    border-radius: 14px !important;
    text-align: left !important;
  }

  body :where(h1, .hero-title, .section-title, .edu-banner-title) {
    font-size: clamp(1.7rem, 9vw, 2.45rem) !important;
    line-height: 1.12 !important;
    letter-spacing: 0 !important;
  }

  body :where(h2) {
    font-size: clamp(1.15rem, 6vw, 1.6rem) !important;
    line-height: 1.24 !important;
    letter-spacing: 0 !important;
  }

  body :where(h3) {
    font-size: clamp(0.98rem, 4.8vw, 1.25rem) !important;
    line-height: 1.28 !important;
  }

  body :where(p, li) {
    font-size: clamp(0.84rem, 3.8vw, 0.98rem) !important;
    line-height: 1.58 !important;
  }

  body :where(a, button, .btn, [class*="btn"], [class*="button"], [class*="chip"], [class*="badge"], [class*="pill"], [class*="tag"], [class*="status"]) {
    white-space: normal !important;
    max-width: 100% !important;
  }

  body :where(.hero-actions, .action-buttons, .support-auth-actions, .support-section-actions, .modal-actions, .search-form, .search-section, .category-search-form, .series-search-form, .note-actions) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    width: 100% !important;
  }

  body :where(.hero-actions > *, .action-buttons > *, .support-auth-actions > *, .support-section-actions > *, .modal-actions > *, .search-form > *, .search-section > *, .note-actions > *) {
    width: 100% !important;
    justify-content: center !important;
  }

  body :where(.sq-header-container, .support-topbar, .policy-nav, .header, .navbar, .topbar) {
    max-width: 100% !important;
  }

  body :where(.sq-nav, .support-topbar-actions, .policy-nav) {
    gap: 8px !important;
  }

  body :where(.policy-card::before, .card::before, .section::before) {
    max-width: 100% !important;
  }
}

@media (max-width: 420px) {
  body :where(main, .container, .wrap, .page, .shell, .support-shell-page, .policy-shell, .about-page, .about-v2, .pyqs-page, .notes-page) {
    width: calc(100vw - 12px) !important;
    max-width: calc(100vw - 12px) !important;
  }

  body :where(.card, .section, .panel, .tile, .item, .hero-card, .support-card, .policy-card, .note-card, .pdf-card, .video-card, .about-value-card, .about-team-card, .series-card, .category-item) {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  body :where(h1, .hero-title, .section-title, .edu-banner-title) {
    font-size: clamp(1.48rem, 10vw, 2rem) !important;
  }

  body :where(.hero-art, .policy-hero-art, .support-hero-visual, .about-hero-visual, .hero-visual, .hero-media) {
    display: none !important;
  }
}

/* Component-level polish for the small UI issues found during mobile checks. */
body :where(button, .btn, [class*="btn"], .action-btn, .home-link, .note-btn, .btn-view, .btn-download, .start-btn, .pyq-search-btn, .hero-secondary-btn, .edu-banner-btn) {
  position: relative;
  overflow: hidden;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
}

body :where(button, .btn, [class*="btn"], .action-btn, .home-link, .note-btn, .btn-view, .btn-download, .start-btn, .pyq-search-btn, .hero-secondary-btn, .edu-banner-btn):hover {
  transform: translateY(-1px);
}

body :where(button, .btn, [class*="btn"], .action-btn, .home-link, .note-btn, .btn-view, .btn-download, .start-btn, .pyq-search-btn, .hero-secondary-btn, .edu-banner-btn):active {
  transform: translateY(0) scale(0.98);
}

body :where(button, .btn, [class*="btn"], .action-btn, .home-link, .note-btn, .btn-view, .btn-download, .start-btn, .pyq-search-btn, .hero-secondary-btn, .edu-banner-btn)::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 0 38%, rgba(255, 255, 255, 0.26) 48%, transparent 58% 100%);
  transform: translateX(-120%);
  transition: transform 0.46s ease;
}

body :where(button, .btn, [class*="btn"], .action-btn, .home-link, .note-btn, .btn-view, .btn-download, .start-btn, .pyq-search-btn, .hero-secondary-btn, .edu-banner-btn):hover::after {
  transform: translateX(120%);
}

body:has(.auth-shell) .register-guidance {
  grid-template-columns: 58px minmax(0, 1fr) !important;
  align-items: start !important;
  gap: 8px 16px !important;
  border-radius: 14px !important;
  background: #ffffff !important;
  box-shadow: 0 12px 28px rgba(49, 93, 244, 0.06) !important;
}

body:has(.auth-shell) .register-guidance i {
  grid-row: 1 / span 2 !important;
  width: 58px !important;
  height: 58px !important;
  border-radius: 16px !important;
  color: #ffffff !important;
  background: linear-gradient(145deg, #315df4, #6b7cff) !important;
  font-size: 1.28rem !important;
  box-shadow: 0 12px 22px rgba(49, 93, 244, 0.22) !important;
}

body:has(.auth-shell) .register-guidance strong {
  color: #10172a !important;
  font-size: 1rem !important;
  line-height: 1.35 !important;
}

body:has(.auth-shell) .register-guidance span {
  color: #5f6b85 !important;
  line-height: 1.55 !important;
}

body:has(.auth-shell) .login-helper-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 12px !important;
}

body:has(.auth-shell) .forgot-link {
  width: auto !important;
  min-width: max-content !important;
  padding: 8px 12px !important;
  border-radius: 999px !important;
  background: #eef4ff !important;
  color: #315df4 !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
}

body:has(.auth-shell) .login-assist-card li {
  grid-template-columns: 28px minmax(0, 1fr) !important;
}

body:has(.auth-shell) .login-assist-card li i {
  width: 28px !important;
  text-align: center !important;
}

body#notes-page .notes-overview {
  grid-template-columns: minmax(0, 1fr) !important;
  width: min(260px, 100%) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

body#notes-page #notesFavoriteCount,
body#notes-page .overview-card .fa-star {
  display: none !important;
}

body#notes-page .ticker p {
  color: #334155 !important;
}

body.testseries-body .hero-stat {
  padding: 18px 72px 16px 22px !important;
}

body.testseries-body .hero-stat::after {
  z-index: 0 !important;
  opacity: 0.28 !important;
}

body.testseries-body .hero-stat strong,
body.testseries-body .hero-stat span {
  position: relative !important;
  z-index: 1 !important;
}

@media (max-width: 680px) {
  body:has(.auth-shell) .auth-shell {
    width: 100% !important;
    max-width: 100% !important;
  }

  body:has(.auth-shell) .auth-panel {
    display: block !important;
  }

  body:has(.auth-shell) .info-pane {
    border-radius: 0 !important;
    padding: 22px 18px 14px !important;
  }

  body:has(.auth-shell) .form-pane {
    width: calc(100% - 16px) !important;
    max-width: calc(100% - 16px) !important;
    margin: -4px auto 0 !important;
    padding: 20px 16px !important;
    border-radius: 18px !important;
  }

  body:has(.auth-shell) .register-guidance {
    grid-template-columns: 48px minmax(0, 1fr) !important;
    padding: 14px !important;
  }

  body:has(.auth-shell) .register-guidance i {
    width: 48px !important;
    height: 48px !important;
    border-radius: 14px !important;
  }

  body:has(.auth-shell) .login-helper-row {
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
  }

  body:has(.auth-shell) .forgot-link {
    width: 100% !important;
    min-width: 0 !important;
    text-align: center !important;
    justify-content: center !important;
  }

  body:has(.auth-shell) .remember-check {
    align-items: center !important;
  }

  .pyqs-hero-copy::before {
    display: none !important;
  }

  .pyqs-kicker,
  .pyqs-hero-copy h1,
  .pyqs-hero-copy p,
  .hero-panel-note {
    margin-left: 0 !important;
    max-width: 100% !important;
  }

  .pyqs-hero-copy,
  .pyqs-hero-panel {
    min-height: 0 !important;
    padding: 20px 16px !important;
  }

  .pyqs-hero-panel {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .hero-stat,
  body.testseries-body .hero-stat {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    padding: 16px !important;
  }

  .hero-stat-icon,
  body.testseries-body .hero-stat::after {
    position: static !important;
    transform: none !important;
    opacity: 1 !important;
  }

  .hero-stat-label {
    grid-column: 1 / -1 !important;
    margin-top: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body :where(button, .btn, [class*="btn"], .action-btn, .home-link, .note-btn, .btn-view, .btn-download, .start-btn, .pyq-search-btn, .hero-secondary-btn, .edu-banner-btn),
  body :where(button, .btn, [class*="btn"], .action-btn, .home-link, .note-btn, .btn-view, .btn-download, .start-btn, .pyq-search-btn, .hero-secondary-btn, .edu-banner-btn)::after {
    transition: none !important;
  }
}
