/* ==========================================================================
   KAVYAHUB - GLOBAL RESPONSIVE ENGINE (MOBILE & DESKTOP SYNCHRONIZED)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. LAPTOPS & SMALL DESKTOPS (<= 1100px)
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  section {
    padding: 56px 5%;
  }

  .navbar {
    padding: 15px 5%;
  }

  .resources-grid,
  .latest-grid,
  .category-grid,
  .social-cards {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
  }

  .guide-video-card {
    gap: 24px;
    padding: 26px;
  }
}

/* --------------------------------------------------------------------------
   2. TABLETS & SMALL LAPTOPS (<= 992px)
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  /* Dynamic "How to Use KavyaHub" Video Section Stacks Cleanly */
  .guide-video-card {
    grid-template-columns: 1fr !important;
    gap: 22px;
    padding: 24px;
  }

  .guide-video-player-wrap {
    width: 100%;
    order: -1; /* Places the 16:9 walkthrough video on top for immediate viewing */
  }

  /* Featured Video Card 16:9 Stack */
  .featured-video-layout {
    grid-template-columns: 1fr !important;
    gap: 18px;
  }

  .featured-video-thumb-wrap {
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: 16 / 9;
  }
}

/* --------------------------------------------------------------------------
   3. TABLETS & LARGE SMARTPHONES (<= 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  section {
    padding: 44px 4%;
  }

  .navbar {
    padding: 13px 4%;
  }

  .menu-icon {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    color: var(--text-main);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
  }

  /* Slide-out Navigation Drawer */
  .nav-links {
    position: fixed;
    top: 68px;
    right: -100%;
    width: 82%;
    max-width: 320px;
    height: calc(100dvh - 68px);
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 24px 18px;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 8px;
    z-index: 999;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.12);
    overflow-y: auto;
  }

  .dark-mode .nav-links {
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.55);
  }

  .nav-links.active {
    right: 0;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
  }

  /* Compact & Balanced Hero Section Reflow */
  .hero-section {
    min-height: auto;
    padding: 44px 4% 38px;
  }

  .profile-image-box {
    margin-bottom: 12px;
  }

  .profile-image {
    width: 96px !important;
    height: 96px !important;
  }

  .hero-content h1 {
    font-size: 1.95rem;
    line-height: 1.25;
  }

  .hero-bio {
    font-size: 0.94rem;
    margin-bottom: 18px;
  }

  /* Hero Search Box & Quick Filter Pills */
  .hero-search-box {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    width: 100%;
  }

  .hero-search-input-wrap {
    width: 100%;
  }

  .hero-search-btn {
    width: 100% !important;
    max-width: none !important;
  }

  .quick-filter-pills {
    justify-content: center;
    gap: 8px;
  }

  .hero-buttons {
    flex-direction: column;
    width: 100%;
    align-items: center;
    gap: 10px;
  }

  .btn {
    width: 100%;
    max-width: 340px;
    text-align: center;
    justify-content: center;
  }

  .section-heading h1,
  .section-heading h2 {
    font-size: 1.65rem;
  }

  /* 1-Click Sector Quick Bar */
  .sector-quick-bar {
    gap: 8px;
    padding: 0 4px;
    justify-content: center;
    flex-wrap: wrap;
  }

  .sector-quick-btn {
    font-size: 0.84rem;
    padding: 9px 14px;
  }

  /* Search & Filter Containers */
  .search-box {
    max-width: 100%;
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  .calendar-box {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  .calendar-keyword-divider {
    display: none;
  }

  .calendar-box input[type="date"],
  .calendar-keyword-input,
  .calendar-box .filter-toggle-btn {
    width: 100% !important;
  }

  .search-suggestions-box {
    width: calc(100% - 16px) !important;
    left: 8px !important;
    transform: none !important;
    max-width: none !important;
  }

  /* Count & Sort Bar */
  .resource-count-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .resource-sort-wrap {
    width: 100%;
    justify-content: space-between;
  }

  .resource-sort-select {
    flex: 1;
  }

  /* Horizontal Filter Tag Slider */
  .filter-container,
  .trending-chips-container {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .filter-container::-webkit-scrollbar,
  .trending-chips-container::-webkit-scrollbar {
    display: none;
  }

  .video-filter-btn,
  .trending-chip {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* YouTube-Style Horizontal Video Card Mobile Transformation */
  .youtube-video-card {
    flex-direction: column !important;
    gap: 14px;
    padding: 16px;
  }

  .youtube-thumb-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: 16 / 9;
  }

  .youtube-content-wrapper {
    width: 100%;
  }

  /* Featured Card Actions */
  .featured-card-actions,
  .featured-actions {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .featured-card-actions button,
  .featured-actions button {
    width: 100%;
    justify-content: center;
  }

  /* Grids Stack */
  .resources-grid,
  .latest-grid,
  .category-grid,
  .social-cards {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .sector-filter-container,
  .video-sector-filters-wrapper {
    justify-content: flex-start !important;
    padding: 0 4px;
    flex-wrap: wrap;
  }

  /* Admin Dashboard Mobile Adjustments */
  .job-meta-inputs-row,
  .hackathon-meta-inputs-row {
    grid-template-columns: 1fr !important;
  }
}

/* --------------------------------------------------------------------------
   4. MOBILE BOTTOM SHEET & DIALOGS (<= 600px)
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Popups convert to Mobile Bottom Sheets */
  .popup-overlay,
  .description-modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    padding: 0 !important;
    align-items: flex-end !important;
    justify-content: center;
    background: rgba(0, 0, 0, 0.62) !important;
    backdrop-filter: blur(6px);
    z-index: 2000;
  }

  .popup-box,
  .description-modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 86dvh !important;
    border-radius: 22px 22px 0 0 !important;
    margin: 0 !important;
    padding: 22px 18px 26px !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25) !important;
    animation: slideUpSheet 0.25s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
    overflow-y: auto;
  }

  @keyframes slideUpSheet {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .modal-action-row,
  .popup-buttons {
    flex-direction: column !important;
    width: 100% !important;
    gap: 10px !important;
  }

  .modal-action-row button,
  .modal-action-row a,
  .popup-social-btn,
  .continue-btn {
    width: 100% !important;
    justify-content: center;
    text-align: center;
  }

  .filter-panel-section {
    padding: 0 4%;
  }

  .filter-options-grid {
    grid-template-columns: 1fr 1fr;
  }

  .guide-video-card {
    padding: 18px;
  }

  .guide-video-info h2 {
    font-size: 1.3rem;
  }
}

/* --------------------------------------------------------------------------
   5. ULTRA-SMALL PORTRAIT DEVICES (<= 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  section {
    padding: 36px 3.5%;
  }

  .logo a {
    font-size: 1.3rem;
  }

  .hero-badge {
    font-size: 0.74rem;
    padding: 5px 12px;
  }

  .hero-content h1 {
    font-size: 1.65rem;
  }

  .section-heading h1,
  .section-heading h2 {
    font-size: 1.45rem;
  }

  .profile-image {
    width: 86px !important;
    height: 86px !important;
  }

  .quick-pill {
    font-size: 0.78rem;
    padding: 6px 11px;
  }

  .sector-quick-btn {
    flex: 1 1 auto;
    justify-content: center;
    font-size: 0.8rem;
    padding: 8px 10px;
  }

  .resource-card,
  .category-card,
  .social-card {
    padding: 16px;
  }

  .card-actions {
    gap: 8px;
  }

  .open-resource-btn,
  .watch-btn {
    font-size: 0.85rem;
    padding: 10px 12px;
  }

  .filter-options-grid {
    grid-template-columns: 1fr;
  }
}