/**
 * Site-wide responsive overrides for LearnPath frontend.
 * Loaded after main.css — keeps layout usable at every common viewport.
 */

/* -------------------------------------------------------------------------- */
/* Global safety                                                              */
/* -------------------------------------------------------------------------- */
html {
  overflow-x: clip;
}

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

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

.table-responsive {
  -webkit-overflow-scrolling: touch;
}

/* Containers should never force horizontal scroll */
.container,
.container-fluid,
.container-xl,
.header-container {
  max-width: 100%;
}

/* -------------------------------------------------------------------------- */
/* Header — remove fixed 100px padding, unify tablet/mobile                   */
/* -------------------------------------------------------------------------- */
.header .header-container,
.header-container {
  padding-left: clamp(12px, 3vw, 24px) !important;
  padding-right: clamp(12px, 3vw, 24px) !important;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.header .logo img,
#desktop-logo {
  max-height: 48px;
  width: auto;
}

#mobile-logo {
  width: 48px !important;
  max-width: 48px;
  height: auto;
}

.notifications-dropdown-menu {
  min-width: min(350px, calc(100vw - 24px)) !important;
  max-width: calc(100vw - 24px) !important;
  max-height: min(500px, 70vh) !important;
}

.user-dropdown-menu {
  min-width: min(260px, calc(100vw - 24px)) !important;
  max-width: calc(100vw - 24px) !important;
}

.cart-dropdown-menu {
  min-width: min(320px, calc(100vw - 24px)) !important;
  max-width: calc(100vw - 24px) !important;
}

/* Align stacked header with nav mobile breakpoint (xl = 1200) */
@media (max-width: 1199.98px) {
  .header .header-container {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .header .logo {
    order: 0;
    width: auto;
    max-width: 50%;
  }

  .header .header-actions {
    order: 0;
    margin-inline-start: auto !important;
    margin-inline-end: 0 !important;
  }

  /* Keep nav full-width when open on tablet */
  .header .navmenu {
    order: 2;
    width: 100%;
  }

  .header .mobile-nav-toggle {
    font-size: 1.6rem;
    line-height: 1;
    padding: 0.35rem;
    cursor: pointer;
  }
}

@media (max-width: 575.98px) {
  .header .logo img,
  #desktop-logo {
    max-height: 40px;
  }

  .btn-getstarted {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem !important;
    white-space: nowrap;
  }

  .header .header-actions {
    gap: 0.5rem !important;
  }

  .btn-language,
  .btn-cart,
  .btn-notifications,
  .btn-user,
  .btn-conversations {
    font-size: 1.25rem;
    padding: 0.25rem;
  }
}

/* -------------------------------------------------------------------------- */
/* Hero — fluid type, wrap rows, contain floats                               */
/* -------------------------------------------------------------------------- */
.courses-hero .hero-text h1 {
  font-size: clamp(1.6rem, 2.5vw + 1rem, 3.25rem) !important;
  line-height: 1.25 !important;
  word-break: break-word;
}

.courses-hero .hero-text p {
  font-size: clamp(0.95rem, 0.4vw + 0.85rem, 1.125rem);
}

.courses-hero .hero-content {
  min-height: auto !important;
}

.courses-hero .hero-stats,
.courses-hero .hero-features,
.courses-hero .hero-buttons {
  flex-wrap: wrap !important;
  max-width: 100%;
}

/* -------------------------------------------------------------------------- */
/* Hero floating cards — fluid scale, always fully visible (no clipping)      */
/* -------------------------------------------------------------------------- */
.courses-hero .hero-image {
  position: relative;
  overflow: visible;
  max-width: 100%;
  /* Raise the banner image so it sits closer to the header */
  margin-top: -2.5rem;
  align-self: flex-start;
}

.courses-hero .hero-image .main-image {
  max-width: 100%;
  overflow: visible;
}

.courses-hero .hero-image .main-image img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center top;
  transform: translateY(-18px);
}

.courses-hero .hero-image .floating-cards {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}

/* Fluid card size: scales with the image column, never a fixed 200px min */
.courses-hero .hero-image .floating-cards .course-card {
  position: absolute !important;
  display: flex !important;
  align-items: center;
  gap: clamp(0.35rem, 1.2%, 0.75rem) !important;
  min-width: 0 !important;
  width: clamp(8.5rem, 32%, 13.5rem) !important;
  max-width: 42% !important;
  padding: clamp(0.45rem, 1.8%, 0.9rem) clamp(0.55rem, 2.2%, 1.1rem) !important;
  border-radius: clamp(0.55rem, 1.5vw, 0.95rem) !important;
  box-shadow: 0 clamp(4px, 0.8vw, 12px) clamp(12px, 2vw, 28px) rgba(0, 0, 0, 0.12) !important;
  /* Keep cards inside image bounds — no negative offsets */
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  transform-origin: center center;
}

.courses-hero .hero-image .floating-cards .course-card .card-icon {
  width: clamp(1.75rem, 8%, 2.75rem) !important;
  height: clamp(1.75rem, 8%, 2.75rem) !important;
  min-width: clamp(1.75rem, 8%, 2.75rem) !important;
  border-radius: clamp(0.4rem, 1vw, 0.75rem) !important;
  flex-shrink: 0;
}

.courses-hero .hero-image .floating-cards .course-card .card-icon i {
  font-size: clamp(0.85rem, 2.2vw, 1.35rem) !important;
}

.courses-hero .hero-image .floating-cards .course-card .card-content {
  min-width: 0;
  overflow: hidden;
}

.courses-hero .hero-image .floating-cards .course-card .card-content h6 {
  font-size: clamp(0.65rem, 1.35vw, 0.9rem) !important;
  margin: 0 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.courses-hero .hero-image .floating-cards .course-card .card-content span {
  font-size: clamp(0.55rem, 1.1vw, 0.8rem) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
}

/* Card 1 — top / start (inside bounds) */
.courses-hero .hero-image .floating-cards .course-card:nth-child(1) {
  top: 10% !important;
  inset-inline-start: 3% !important;
  inset-inline-end: auto !important;
}

/* Card 2 — mid / end */
.courses-hero .hero-image .floating-cards .course-card:nth-child(2) {
  top: 42% !important;
  inset-inline-end: 3% !important;
  inset-inline-start: auto !important;
}

/* Card 3 — bottom / start — was clipped when left was negative */
.courses-hero .hero-image .floating-cards .course-card:nth-child(3) {
  bottom: 8% !important;
  top: auto !important;
  inset-inline-start: 6% !important;
  inset-inline-end: auto !important;
}

@media (min-width: 992px) {
  .courses-hero {
    padding-top: 100px;
    padding-bottom: 40px;
    align-items: flex-start;
    overflow: visible;
  }

  .courses-hero .hero-content {
    align-items: flex-start !important;
    min-height: auto !important;
    padding-top: 0.5rem;
  }

  .courses-hero .hero-image {
    margin-top: -3.5rem;
  }

  .courses-hero .hero-image .main-image img {
    transform: translateY(-28px);
  }
}

@media (min-width: 1200px) {
  .courses-hero .hero-image .floating-cards .course-card {
    width: clamp(9.5rem, 30%, 14rem) !important;
  }
}

@media (min-width: 1400px) {
  .courses-hero .hero-image {
    margin-top: -4rem;
  }

  .courses-hero .hero-image .main-image img {
    transform: translateY(-36px);
  }

  .courses-hero .hero-image .floating-cards .course-card {
    width: clamp(10.5rem, 28%, 15rem) !important;
  }
}

/* Between lg and xl: show scaled cards (don't hide until tablet) */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .courses-hero .hero-image .floating-cards {
    display: block !important;
  }

  .courses-hero .hero-image .floating-cards .course-card {
    display: flex !important;
    width: clamp(7.5rem, 34%, 11rem) !important;
    max-width: 40% !important;
  }
}

/* Hide floating cards only on small tablets / phones */
@media (max-width: 991.98px) {
  .courses-hero .hero-image .floating-cards {
    display: none !important;
  }

  .courses-hero {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }

  .courses-hero .hero-image {
    margin-top: -1rem;
  }

  .courses-hero .hero-image .main-image img {
    transform: translateY(-8px);
  }

  .courses-hero .hero-content {
    text-align: center;
  }

  .courses-hero .hero-stats,
  .courses-hero .hero-features,
  .courses-hero .hero-buttons {
    justify-content: center !important;
  }
}

@media (max-width: 767.98px) {
  .courses-hero .hero-buttons .btn {
    width: 100%;
  }

  .courses-hero .hero-stats .stat-item {
    flex: 1 1 30%;
    min-width: 90px;
  }
}

/* -------------------------------------------------------------------------- */
/* CTA floating elements                                                      */
/* -------------------------------------------------------------------------- */
.cta .cta-image {
  position: relative;
  overflow: hidden;
  max-width: 100%;
}

@media (max-width: 991.98px) {
  .cta .cta-image .floating-element {
    display: none !important;
  }
}

@media (min-width: 992px) {
  .cta .cta-image .floating-element.student-card {
    right: 12px;
  }

  .cta .cta-image .floating-element.course-card {
    left: 12px;
  }
}

/* -------------------------------------------------------------------------- */
/* Sections / cards / grids                                                   */
/* -------------------------------------------------------------------------- */
.section {
  overflow-x: clip;
}

.section .row > [class*="col-"] {
  min-width: 0;
}

.card,
.course-card,
.subscription-card,
.library-card {
  max-width: 100%;
}

.section img {
  max-width: 100%;
  height: auto;
}

/* Page titles / breadcrumbs */
.page-title .container,
.breadcrumbs .container {
  padding-left: clamp(12px, 3vw, 16px);
  padding-right: clamp(12px, 3vw, 16px);
}

/* -------------------------------------------------------------------------- */
/* Contact page — prevent mobile horizontal overflow                          */
/* -------------------------------------------------------------------------- */
.contact .contact-main-wrapper,
.contact .contact-content,
.contact .contact-form-container,
.contact .map-wrapper,
.contact #contact-form {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.contact .map-wrapper iframe {
  max-width: 100%;
}

@media (max-width: 767.98px) {
  .contact .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .contact .contact-form-container {
    padding: 1rem !important;
  }

  .contact #contact-form {
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
  }

  .contact #contact-form .form-check {
    min-width: 0 !important;
    width: 100% !important;
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    overflow: visible !important;
    padding-inline-start: 1rem !important;
    padding-inline-end: 1rem !important;
    box-sizing: border-box;
  }

  .contact #contact-form .form-check-input {
    float: none !important;
    margin: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    position: relative !important;
    flex-shrink: 0;
    order: 2;
  }

  .contact #contact-form .form-check-label {
    margin: 0 !important;
    padding: 0 !important;
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }

  .contact #contact-form .contact-type-options,
  .contact #contact-form .form-group > .d-flex {
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
  }

  .contact .contact-card .contact-text {
    min-width: 0;
    flex: 1 1 auto;
  }

  .contact .contact-card .contact-text p,
  .contact .contact-form-container h3,
  .contact .contact-form-container > p,
  .contact .form-label {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Keep scroll-top clear of form inputs */
  #scroll-top {
    bottom: 1rem;
    inset-inline-end: 1rem;
    z-index: 10;
  }
}

/* Auth / forms */
.auth-form,
.auth-card,
.profile-form,
form {
  max-width: 100%;
}

input,
select,
textarea,
.form-control,
.form-select {
  max-width: 100%;
}

/* Course / library detail media */
.course-details video,
.course-details iframe,
.lesson-player,
.ratio {
  max-width: 100%;
}

/* Subscriptions page title scale */
.subscriptions-page .page-main-title {
  font-size: clamp(1.5rem, 2vw + 1rem, 2.5rem) !important;
}

@media (max-width: 767.98px) {
  .subscriptions-page {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* Cart table cards on small screens */
@media (max-width: 575.98px) {
  .table-responsive table {
    font-size: 0.875rem;
  }
}

/* Footer */
.footer .container {
  padding-left: clamp(12px, 3vw, 16px);
  padding-right: clamp(12px, 3vw, 16px);
}

.footer .row > [class*="col-"] {
  margin-bottom: 1rem;
}

/* Modals / toasts never exceed viewport */
.modal-dialog {
  margin: 0.75rem auto;
  max-width: min(500px, calc(100vw - 1.5rem));
}

.toast-container {
  max-width: calc(100vw - 1rem);
}

/* Filter sidebars on small screens */
@media (max-width: 991.98px) {
  .course-filters {
    margin-bottom: 1.25rem;
  }
}

/* Prevent absolute decorative logos from spilling */
@media (max-width: 991.98px) {
  .watermark,
  .section-watermark,
  [style*="127.0.0.1"] {
    background-size: contain !important;
    opacity: 0.08 !important;
  }
}
