/*
 * NextGen Sarkari homepage mobile density fixes
 * Scope: homepage only. Existing theme, desktop layout and API rendering are preserved.
 */

@media (max-width: 768px) {
  body.home-page .main-content {
    overflow-x: hidden;
  }

  /* Make the summary blocks useful without consuming most of the first screen. */
  body.home-page .stat-grid {
    gap: 9px !important;
    margin-block: 14px 22px !important;
  }

  body.home-page .stat-card {
    min-height: 76px !important;
    padding: 12px 10px !important;
    border-radius: 17px !important;
  }

  body.home-page .stat-card span {
    font-size: 1.35rem !important;
    line-height: 1.1 !important;
  }

  body.home-page .stat-card small {
    margin-top: 4px !important;
    font-size: 0.78rem !important;
    line-height: 1.25 !important;
  }

  /* Compact Quick Access cards. */
  body.home-page .category-grid {
    gap: 10px !important;
  }

  body.home-page .category-card {
    min-height: 108px !important;
    padding: 12px 10px !important;
    gap: 7px !important;
    border-radius: 18px !important;
  }

  body.home-page .category-card .icon {
    width: 42px !important;
    height: 42px !important;
    margin: 0 auto 5px !important;
    border-radius: 14px !important;
    font-size: 1.1rem !important;
  }

  body.home-page .category-card p {
    margin: 0 !important;
    font-size: 0.84rem !important;
    line-height: 1.25 !important;
  }

  /*
   * Latest Jobs and Study Materials become swipeable rows on phones.
   * This prevents six full-width cards from making the homepage excessively long.
   */
  body.home-page #homeJobsGrid,
  body.home-page #homeStudyGrid {
    display: grid !important;
    grid-template-columns: none !important;
    grid-auto-flow: column !important;
    grid-auto-columns: min(84vw, 326px) !important;
    gap: 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
    scroll-padding-inline: 2px;
    padding: 4px 18px 14px 2px !important;
    margin-right: -16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  body.home-page #homeJobsGrid::-webkit-scrollbar,
  body.home-page #homeStudyGrid::-webkit-scrollbar {
    display: none;
  }

  body.home-page #homeJobsGrid > *,
  body.home-page #homeStudyGrid > * {
    scroll-snap-align: start;
  }

  body.home-page #homeJobsGrid .job-card,
  body.home-page #homeStudyGrid .paper-card {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 14px !important;
    gap: 9px !important;
    border-radius: 19px !important;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07) !important;
  }

  body.home-page #homeJobsGrid .card-top,
  body.home-page #homeStudyGrid .card-top {
    gap: 8px !important;
  }

  body.home-page #homeJobsGrid .badge,
  body.home-page #homeStudyGrid .badge {
    align-self: flex-start;
    width: auto !important;
    margin: 0 !important;
    padding: 5px 9px !important;
    font-size: 0.68rem !important;
    line-height: 1 !important;
  }

  body.home-page #homeJobsGrid h3,
  body.home-page #homeStudyGrid h3 {
    margin: 0 !important;
    font-size: 1rem !important;
    line-height: 1.32 !important;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  body.home-page #homeJobsGrid .job-info,
  body.home-page #homeStudyGrid .paper-info {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  body.home-page #homeJobsGrid .job-info span,
  body.home-page #homeStudyGrid .paper-info span {
    min-width: 0;
    padding: 7px 8px !important;
    border-radius: 10px !important;
    font-size: 0.72rem !important;
    line-height: 1.2 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.home-page #homeJobsGrid .card-copy,
  body.home-page #homeStudyGrid .card-copy {
    min-height: 0 !important;
    margin: 0 !important;
    font-size: 0.79rem !important;
    line-height: 1.38 !important;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  body.home-page #homeJobsGrid .card-footer,
  body.home-page #homeStudyGrid .actions {
    margin-top: auto !important;
    gap: 7px !important;
  }

  body.home-page #homeJobsGrid .card-button,
  body.home-page #homeStudyGrid .card-button {
    min-height: 42px !important;
    width: auto !important;
    padding: 10px 13px !important;
    border-radius: 12px !important;
    font-size: 0.82rem !important;
    line-height: 1.1 !important;
  }

  body.home-page #homeStudyGrid .home-study-card-thumb,
  body.home-page #homeStudyGrid .home-study-card-icon {
    height: 112px !important;
    margin-bottom: 1px !important;
    border-radius: 14px !important;
    object-fit: cover;
  }

  /* Keep section headings on one compact row. */
  body.home-page .main-content section:has(#homeJobsGrid),
  body.home-page .main-content section:has(#homeStudyGrid) {
    padding-block: 22px !important;
  }

  body.home-page .main-content section:has(#homeJobsGrid) .section-headline,
  body.home-page .main-content section:has(#homeStudyGrid) .section-headline {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    margin: 0 0 12px !important;
  }

  body.home-page .main-content section:has(#homeJobsGrid) .section-headline--accent span:last-child,
  body.home-page .main-content section:has(#homeStudyGrid) .section-headline--accent span:last-child {
    font-size: 1.28rem !important;
    line-height: 1.2 !important;
  }

  body.home-page .main-content section:has(#homeJobsGrid) .section-icon,
  body.home-page .main-content section:has(#homeStudyGrid) .section-icon {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    font-size: 1rem !important;
  }

  body.home-page .main-content section:has(#homeJobsGrid) .section-cta,
  body.home-page .main-content section:has(#homeStudyGrid) .section-cta {
    flex: 0 0 auto;
    width: auto !important;
    margin: 0 !important;
    padding: 8px 11px !important;
    border-radius: 11px !important;
    font-size: 0.72rem !important;
    white-space: nowrap;
  }
}

@media (max-width: 359px) {
  body.home-page #homeJobsGrid,
  body.home-page #homeStudyGrid {
    grid-auto-columns: 88vw !important;
  }

  body.home-page .main-content section:has(#homeJobsGrid) .section-headline--accent span:last-child,
  body.home-page .main-content section:has(#homeStudyGrid) .section-headline--accent span:last-child {
    font-size: 1.12rem !important;
  }

  body.home-page .main-content section:has(#homeJobsGrid) .section-cta,
  body.home-page .main-content section:has(#homeStudyGrid) .section-cta {
    font-size: 0.66rem !important;
    padding-inline: 9px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.home-page #homeJobsGrid,
  body.home-page #homeStudyGrid {
    scroll-behavior: auto;
  }
}

/* ================================================================
   Latest Jobs: compact four-item swipe carousel (desktop + mobile)
   Scope: homepage latest jobs section only.
   ================================================================ */
body.home-page .home-jobs-section {
  min-width: 0;
}

body.home-page .home-jobs-section .section-headline {
  margin: 42px 0 18px;
  padding: 4px 0;
  flex-wrap: nowrap;
}

body.home-page .home-jobs-section .section-headline-title {
  min-width: 0;
  gap: 10px;
}

body.home-page .home-jobs-section .section-accent-line {
  width: 4px;
  height: 30px;
}

body.home-page .home-jobs-section .section-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  font-size: 1rem;
}

body.home-page .home-jobs-section .section-headline--accent #homeLatestJobsHeading {
  font-size: clamp(1.42rem, 1.7vw, 1.78rem) !important;
  line-height: 1.15;
}

body.home-page .home-jobs-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

body.home-page .home-jobs-scroll {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 11px;
  background: #ffffff;
  color: var(--blue);
  box-shadow: 0 7px 18px rgba(15, 23, 42, 0.06);
  font: inherit;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease,
    border-color 0.18s ease, opacity 0.18s ease;
}

body.home-page .home-jobs-scroll:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(37, 99, 235, 0.07);
  border-color: rgba(37, 99, 235, 0.3);
}

body.home-page .home-jobs-scroll:disabled {
  opacity: 0.38;
  cursor: default;
  box-shadow: none;
}

body.home-page .home-jobs-section .section-cta {
  width: auto !important;
  min-height: 36px;
  margin: 0 !important;
  padding: 8px 13px !important;
  border-radius: 11px !important;
  font-size: 0.78rem !important;
  white-space: nowrap;
}

body.home-page #homeJobsGrid.home-jobs-carousel {
  display: grid !important;
  grid-template-columns: none !important;
  grid-auto-flow: column !important;
  grid-auto-columns: minmax(360px, calc((100% - 18px) / 2.18)) !important;
  gap: 16px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline mandatory;
  scroll-padding-inline: 3px;
  scroll-behavior: smooth;
  padding: 4px 18px 14px 3px !important;
  margin-right: -14px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
}

body.home-page #homeJobsGrid.home-jobs-carousel::-webkit-scrollbar {
  display: none;
}

body.home-page #homeJobsGrid.home-jobs-carousel .job-card {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 16px !important;
  gap: 10px !important;
  border-radius: 18px !important;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

body.home-page #homeJobsGrid.home-jobs-carousel .card-top {
  gap: 8px !important;
}

body.home-page #homeJobsGrid.home-jobs-carousel .badge {
  align-self: flex-start;
  width: auto !important;
  margin: 0 !important;
  padding: 5px 9px !important;
  font-size: 0.7rem !important;
  line-height: 1;
}

body.home-page #homeJobsGrid.home-jobs-carousel h3 {
  margin: 0 !important;
  font-size: 1.04rem !important;
  line-height: 1.34 !important;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

body.home-page #homeJobsGrid.home-jobs-carousel .job-info {
  gap: 7px !important;
}

body.home-page #homeJobsGrid.home-jobs-carousel .job-info span {
  min-width: 0;
  padding: 8px 9px !important;
  border-radius: 10px !important;
  font-size: 0.76rem !important;
  line-height: 1.2 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.home-page #homeJobsGrid.home-jobs-carousel .card-copy {
  min-height: 0 !important;
  margin: 0 !important;
  font-size: 0.82rem !important;
  line-height: 1.42 !important;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

body.home-page #homeJobsGrid.home-jobs-carousel .card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: auto !important;
}

body.home-page #homeJobsGrid.home-jobs-carousel .card-button {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 118px;
  min-height: 40px;
  padding: 10px 15px !important;
  border-radius: 11px !important;
  font-size: 0.82rem !important;
  line-height: 1.1;
}

@media (max-width: 900px) {
  body.home-page #homeJobsGrid.home-jobs-carousel {
    grid-auto-columns: minmax(310px, 74vw) !important;
  }
}

@media (max-width: 768px) {
  body.home-page .home-jobs-section .section-headline {
    margin: 0 0 12px !important;
    gap: 8px !important;
  }

  body.home-page .home-jobs-section .section-headline--accent #homeLatestJobsHeading {
    font-size: 1.22rem !important;
  }

  body.home-page .home-jobs-scroll {
    display: none;
  }

  body.home-page .home-jobs-section .section-cta {
    min-height: 34px;
    padding: 7px 10px !important;
    font-size: 0.7rem !important;
  }

  body.home-page #homeJobsGrid.home-jobs-carousel {
    grid-auto-columns: min(84vw, 326px) !important;
    gap: 12px !important;
    padding: 4px 18px 14px 2px !important;
    margin-right: -16px;
  }

  body.home-page #homeJobsGrid.home-jobs-carousel .job-card {
    padding: 14px !important;
    gap: 9px !important;
  }
}

@media (max-width: 390px) {
  body.home-page .home-jobs-section .section-icon {
    display: none;
  }

  body.home-page .home-jobs-section .section-headline--accent #homeLatestJobsHeading {
    font-size: 1.12rem !important;
  }
}

