/* ==========================================================================
   The Guilds Academy - Responsive Media Queries
   Breakpoints: 2200+ (large displays) / 1200 (laptop) / 1100 (nav drawer) /
                992 (tablet) / 768 (small tablet) / 576 (phone) / 380 (small phone)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. FLUID SAFETY NETS (all screen sizes)
   -------------------------------------------------------------------------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-wrap: break-word;
}

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

iframe, video, embed, object {
  max-width: 100%;
}

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

.header-actions {
  flex-shrink: 0;
}

.top-bar-link {
  white-space: nowrap;
}

.mega-menu {
  max-width: calc(100vw - 2rem);
}

.accordion-header {
  gap: 1rem;
}

.course-card-footer {
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-bottom {
  flex-wrap: wrap;
  gap: 1rem;
}

.hero-trust-indicators {
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
}

/* Two-column catalog grid (courses.html) */
.courses-grid.courses-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* Grid children must be allowed to shrink below their content width */
.stack-lg > *,
.stack-md > *,
.stack-sm > *,
.stack-xs > * {
  min-width: 0;
}

/* Extra drawer links, only shown on phones where the top bar is hidden */
.nav-mobile-extras {
  display: none;
}

/* CMS-authored page content (page.html). The .container prefix outranks the
   page's own <style> block, whose padding shorthand drops the side gutters. */
.container.custom-page-content {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.custom-page-content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

/* --------------------------------------------------------------------------
   1. LARGE DISPLAYS (2200px and up)
   -------------------------------------------------------------------------- */
@media (min-width: 2200px) {
  html {
    font-size: 18px;
  }

  :root {
    --container-max-width: 1560px;
  }
}

/* --------------------------------------------------------------------------
   2. LAPTOP & SMALL DESKTOP (Max 1200px)
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .courses-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }

  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .footer-grid {
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 2rem;
  }

  .header-main .brand-logo {
    font-size: 1.2rem;
    gap: 0.6rem;
  }

  .header-main .brand-logo-icon {
    width: 64px;
    height: 64px;
  }

  .nav-menu {
    gap: 1.25rem;
  }

  .hero-title {
    font-size: 2.85rem;
  }
}

/* --------------------------------------------------------------------------
   3. NAVIGATION DRAWER (Max 1100px)
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
  }

  .header-main .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: min(320px, 86vw);
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    background-color: var(--color-surface);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 1rem 1.5rem calc(2rem + var(--topbar-height));
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform var(--transition-normal), visibility var(--transition-normal);
    z-index: 1050;
  }

  .header-main .nav-menu.is-active {
    transform: none;
    visibility: visible;
  }

  body.nav-open {
    overflow: hidden;
  }

  body.nav-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background-color: rgba(11, 31, 51, 0.45);
    z-index: 950;
  }

  .nav-menu .nav-item {
    width: 100%;
  }

  .nav-menu .nav-link {
    justify-content: space-between;
    padding: 0.9rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--color-border);
  }

  /* Chevron doubles as the tap target that expands the mega menu */
  .nav-menu .nav-link i.fa-chevron-down {
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    margin: -0.6rem -0.75rem -0.6rem 0;
  }

  .nav-item:hover:not(.is-open) .nav-link i.fa-chevron-down {
    transform: none;
  }

  .nav-item.has-mega.is-open .nav-link i.fa-chevron-down {
    transform: rotate(180deg);
  }

  .mega-menu {
    position: static;
    width: 100%;
    max-width: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0.5rem 0 0.75rem;
    display: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
  }

  .nav-item.has-mega.is-open .mega-menu {
    display: block;
  }

  .mega-categories-grid {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .mega-category-item {
    padding: 0.6rem 0.25rem;
  }

  .mega-featured-box {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   4. TABLET LAYOUT (Max 992px)
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  :root {
    --header-height: 72px;
  }

  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.85rem; }

  .section {
    padding: 4rem 0;
  }

  .section-title {
    font-size: 1.9rem;
  }

  .header-main .brand-logo-icon {
    width: 56px;
    height: 56px;
  }

  /* Top bar: drop the notice so the links fit */
  .top-bar-links {
    gap: 1.1rem;
  }

  .top-bar-links:first-child .top-bar-link:first-child {
    display: none;
  }

  /* Hero */
  .hero-section {
    padding: 4rem 0 5.5rem;
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .hero-subtitle {
    max-width: 100%;
  }

  .hero-visual-card {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
  }

  .hero-floating-badge {
    left: 1rem;
    bottom: -1.25rem;
    padding: 0.9rem 1.1rem;
  }

  .search-form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
  }

  .search-form-grid .form-input-icon,
  .search-form-grid button {
    grid-column: span 2;
  }

  /* Grids */
  .courses-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem 1.5rem;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
  }

  /* Layout helpers for inline-styled grids */
  .stack-lg {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 2rem !important;
  }

  .cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .hide-lg {
    display: none !important;
  }

  /* Catalog filter sidebar becomes a two-column filter panel */
  .catalog-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1rem;
  }

  .catalog-filters > h3 {
    grid-column: 1 / -1;
  }

  /* Student dashboard sidebar becomes a wrapping tab row */
  .dash-nav {
    flex-direction: row !important;
    flex-wrap: wrap;
  }

  .dash-nav > li {
    flex: 1 1 auto;
  }

  .dash-nav > li > a {
    justify-content: center;
    white-space: nowrap;
  }
}

/* --------------------------------------------------------------------------
   5. SMALL TABLET / LARGE PHONE (Max 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .top-utility-bar .container {
    justify-content: center;
  }

  .top-bar-links:first-child {
    display: none;
  }

  /* Page banners set their heading size inline */
  #main-content h1[style]:not(#dash-welcome) {
    font-size: clamp(1.6rem, 6vw, 2.1rem) !important;
  }

  /* 16px inputs stop iOS Safari from zooming the page on focus */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important;
  }

  .stack-md {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .cols-3 {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1.25rem !important;
  }

  .logo-strip {
    justify-content: center !important;
    gap: 1rem 1.75rem !important;
  }

  .logo-strip > span {
    font-size: 1.05rem !important;
  }

  .header-cta {
    display: none;
  }

  .enroll-item {
    flex-wrap: wrap;
  }

  .enroll-item > div {
    flex: 1 1 220px;
    min-width: 0;
  }

  /* Modals */
  #order-success-modal > div,
  #cert-modal > div {
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
  }

  .container.custom-page-content {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
    font-size: 1rem;
  }

  .custom-page-content [style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* --------------------------------------------------------------------------
   6. MOBILE SCREEN LAYOUT (Max 576px)
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
  :root {
    --header-height: 64px;
  }

  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.1rem; }

  .lead {
    font-size: 1rem;
  }

  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .section {
    padding: 2.75rem 0;
  }

  .section-header {
    margin-bottom: 2rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .btn {
    white-space: normal;
  }

  .btn-lg {
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
  }

  /* Header */
  .top-utility-bar {
    display: none;
  }

  .header-main .brand-logo {
    font-size: 1.02rem;
    line-height: 1.15;
    gap: 0.5rem;
  }

  .header-main .brand-logo-icon {
    width: 46px;
    height: 46px;
  }

  .header-actions {
    gap: 0.4rem;
  }

  /* Sign-in / account button moves into the drawer */
  .header-actions > .js-auth-container {
    display: none;
  }

  .header-main .nav-menu {
    padding-bottom: 2rem;
  }

  .nav-mobile-extras {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: 1.5rem;
  }

  .nav-mobile-extras .btn {
    width: 100%;
  }

  .nav-mobile-extras > a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
  }

  .header-secure-note {
    font-size: 0.75rem !important;
    text-align: right;
  }

  /* Hero */
  .hero-section {
    padding: 2.75rem 0 4.5rem;
  }

  .hero-title {
    font-size: clamp(1.7rem, 7.5vw, 2rem);
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .hero-badge {
    font-size: 0.78rem;
    margin-bottom: 1.1rem;
  }

  .hero-cta-group {
    flex-direction: column;
    width: 100%;
  }

  .hero-cta-group .btn {
    width: 100%;
  }

  .hero-trust-indicators {
    gap: 0.6rem 1.25rem;
  }

  .hero-floating-badge {
    left: 0.75rem;
    gap: 0.75rem;
  }

  .hero-floating-badge .icon-box {
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
  }

  .search-strip-container {
    margin-top: -2rem;
  }

  .search-form-grid {
    grid-template-columns: 1fr;
  }

  .search-form-grid .form-input-icon,
  .search-form-grid button {
    grid-column: span 1;
  }

  /* Grids */
  .courses-grid,
  .courses-grid.courses-grid-2 {
    grid-template-columns: 1fr;
  }

  .course-card-body {
    padding: 1.25rem;
  }

  .course-card-footer {
    padding: 1rem 1.25rem;
  }

  .course-info-list {
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }

  /* Category cards collapse into compact rows */
  .categories-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .category-card {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 1rem;
    row-gap: 0.1rem;
    padding: 1rem 1.25rem;
  }

  .category-card-icon {
    grid-row: span 2;
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
  }

  .category-card-title {
    font-size: 1.02rem;
  }

  .stats-grid {
    gap: 2rem 1rem;
  }

  .stat-item-number {
    font-size: clamp(1.6rem, 8vw, 2.25rem);
  }

  .stat-item-label {
    font-size: 0.875rem;
  }

  .accordion-header {
    padding: 1rem 1.1rem;
    font-size: 0.98rem;
  }

  .accordion-content {
    padding: 0 1.1rem 1rem;
  }

  /* Footer */
  .footer-main {
    padding: 3rem 0 1.5rem;
  }

  .footer-main .brand-logo-icon {
    width: 60px;
    height: 60px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    margin-bottom: 2.5rem;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    padding-top: 1.5rem;
  }

  .footer-bottom > div {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Certificate preview */
  .certificate-preview-box {
    padding: 2rem 1.25rem;
    border-width: 6px;
  }

  .certificate-seal {
    position: static;
    width: 54px;
    height: 54px;
    font-size: 1.35rem;
    margin: 1.25rem auto 0;
  }

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

  .cert-recipient {
    font-size: 1.25rem;
  }

  #cert-modal {
    padding: 0.75rem !important;
  }

  #cert-modal > div {
    padding: 2.75rem 1rem 1.5rem !important;
  }

  /* Toasts & floating button */
  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .scroll-top-btn {
    right: 1rem !important;
    bottom: 1rem !important;
  }

  /* Layout helpers for inline-styled blocks */
  .page-banner {
    padding-top: 2.5rem !important;
    padding-bottom: 2.5rem !important;
  }

  .stack-sm {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .card-pad {
    padding: 1.5rem 1.25rem !important;
  }

  .cart-item {
    flex-wrap: wrap;
    gap: 0.9rem !important;
  }

  .cart-item > img {
    width: 88px !important;
    height: 64px !important;
  }

  .cart-item > div {
    flex: 1 1 0;
    min-width: 0;
  }

  .cart-item > .cart-item-price {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left !important;
  }

  .enroll-item {
    padding: 1.1rem !important;
    gap: 1rem !important;
  }

  .enroll-item > img {
    width: 100% !important;
    height: 150px !important;
  }

  .enroll-item > .btn {
    width: 100%;
  }

  /* Verification record: single column, long IDs may wrap */
  .verify-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 1.1rem !important;
  }

  .verify-grid > * {
    grid-column: auto !important;
    overflow-wrap: anywhere;
  }

  .container.custom-page-content {
    padding: 2rem 1rem;
  }

  .container.custom-page-content h2 {
    font-size: 1.5rem;
  }

  .container.custom-page-content h3 {
    font-size: 1.2rem;
  }

  .container.custom-page-content ul,
  .container.custom-page-content ol {
    margin-left: 1.25rem;
  }
}

/* --------------------------------------------------------------------------
   7. NARROW PHONES (Max 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .stack-xs {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .cols-4 {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .catalog-filters {
    grid-template-columns: 1fr;
  }

  .verify-form {
    flex-direction: column;
  }

  .payment-methods {
    gap: 0.5rem !important;
  }

  .payment-methods > label {
    padding: 0.75rem 0.35rem !important;
  }

  .dash-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }

  .dash-stats > div {
    padding: 0.75rem 0.6rem !important;
  }

  .dash-stats > div > div:first-child {
    font-size: 0.72rem !important;
  }

  .dash-stats > div > div:last-child {
    font-size: 1.5rem !important;
  }

  .dash-nav > li {
    flex: 1 1 100%;
  }

  .dash-nav > li > a {
    justify-content: flex-start;
  }
}

/* --------------------------------------------------------------------------
   8. SMALL PHONES (Max 380px)
   -------------------------------------------------------------------------- */
@media (max-width: 380px) {
  .container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .header-main .brand-logo {
    font-size: 0.95rem;
  }

  .header-main .brand-logo-icon {
    width: 40px;
    height: 40px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .course-card-image-wrap {
    height: 170px;
  }
}

/* --------------------------------------------------------------------------
   9. SHORT LANDSCAPE SCREENS (phones held sideways)
   -------------------------------------------------------------------------- */
@media (max-height: 480px) and (orientation: landscape) {
  .hero-section {
    padding: 2.5rem 0 4rem;
  }

  .header-main .nav-menu {
    padding-top: 0.25rem;
  }

  .nav-menu .nav-link {
    padding: 0.6rem 0;
  }
}

/* --------------------------------------------------------------------------
   10. TOUCH DEVICES & REDUCED MOTION
   -------------------------------------------------------------------------- */
@media (hover: none) {
  .course-card:hover,
  .category-card:hover,
  .btn-primary:hover,
  .btn-navy:hover {
    transform: none;
  }

  .course-card:hover .course-card-img {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
