/* ==========================================================================
   KRAFTING DIGITAL — RESPONSIVE MEDIA QUERIES & MOBILE NAVIGATION
   Tested across all mobile viewports: 320px, 360px, 375px, 390px, 414px, 430px, 768px, 1024px, 1440px
   ========================================================================== */

/* Mobile Offcanvas / Drawer Navigation */
.mobile-nav-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 9, 12, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1080;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.mobile-nav-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: -100%;
  width: min(85vw, 380px);
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  z-index: 1090;
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -15px 0 40px rgba(0, 0, 0, 0.7);
  visibility: hidden;
  pointer-events: none;
}

.mobile-nav-drawer.open {
  right: 0;
  visibility: visible;
  pointer-events: auto;
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.mobile-nav-links {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
  background: var(--bg-elevated);
  color: var(--accent);
}

.mobile-submenu {
  list-style: none;
  padding: 0.25rem 0 0.5rem 1.5rem;
  margin: 0;
  display: none;
}

.mobile-submenu.show {
  display: block;
}

.mobile-submenu-link {
  display: block;
  padding: 0.45rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.mobile-submenu-link:hover {
  color: var(--accent);
}

.mobile-nav-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   BREAKPOINTS
   ========================================================================== */

/* Large Desktops (>= 1200px) */
@media (min-width: 1200px) {
  .container {
    max-width: 1240px;
  }
}

/* Tablets & Below (< 992px) */
@media (max-width: 991.98px) {
  :root {
    --header-height: 72px;
  }

  .nav-links-wrap,
  .nav-action-cta {
    display: none !important;
  }

  .nav-mobile-toggle {
    display: flex !important;
  }

  .hero-section {
    padding-top: 2.5rem;
    padding-bottom: 3.5rem;
  }

  .hero-visual-card {
    margin-top: 2.5rem;
  }

  .section-py {
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
  }

  .project-card-meta {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .search-input-wrapper {
    width: 100%;
  }

  .portfolio-search-input {
    max-width: 100%;
  }

  .footer-bottom-bar {
    flex-direction: column;
    text-align: center;
    gap: 1.25rem;
  }
}

/* Mobile Screens (< 768px) */
@media (max-width: 767.98px) {

  /* Site Header & Mobile Brand Logo */
  .site-header {
    height: 66px !important;
  }

  .nav-brand-logo img {
    width: 165px !important;
    height: auto !important;
  }

  .nav-mobile-toggle {
    width: 42px !important;
    height: 42px !important;
    font-size: 1.35rem !important;
  }

  /* Fluid Typography */
  h1,
  .h1,
  .display-4,
  .display-5 {
    font-size: clamp(1.8rem, 6.5vw, 2.35rem) !important;
    line-height: 1.22 !important;
    word-break: break-word;
    letter-spacing: -0.02em !important;
  }

  h2,
  .h2,
  .display-6 {
    font-size: clamp(1.45rem, 5.2vw, 1.85rem) !important;
    line-height: 1.28 !important;
    word-break: break-word;
  }

  h3,
  .h3 {
    font-size: clamp(1.2rem, 4.2vw, 1.45rem) !important;
    line-height: 1.35 !important;
  }

  .lead {
    font-size: 1rem !important;
    line-height: 1.6 !important;
  }

  /* Universal Banner & Button Mobile Fluidity */
  .hero-section,
  .section-py {
    padding-top: clamp(2rem, 5vw, 3.25rem) !important;
    padding-bottom: clamp(2rem, 5vw, 3.25rem) !important;
  }

  .btn-kraft-primary,
  .btn-kraft-outline,
  .btn-kraft-ghost,
  .btn-kd-primary,
  .btn-kd-secondary {
    max-width: 100%;
    white-space: normal;
    text-align: center;
    word-break: break-word;
  }

  .hero-section .d-flex.gap-3,
  .hero-section .d-flex.flex-wrap,
  .section-py .d-flex.gap-3,
  .section-py .d-flex.flex-wrap {
    gap: 0.75rem !important;
  }

  @media (max-width: 480px) {
    .hero-section .d-flex.gap-3,
    .section-py .d-flex.gap-3 {
      flex-direction: column;
      width: 100%;
    }

    .hero-section .btn-kraft-primary,
    .hero-section .btn-kraft-outline,
    .section-py .btn-kraft-primary,
    .section-py .btn-kraft-outline {
      width: 100%;
    }
  }

  /* Horizontal Smooth-Scroll Filter Pills Bar */
  .filter-pills-bar {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-snap-type: x mandatory;
    gap: 0.55rem !important;
    padding-bottom: 0.75rem !important;
    margin-bottom: 1.5rem !important;
    scrollbar-width: none !important;
    justify-content: flex-start !important;
    width: 100% !important;
  }

  .filter-pills-bar::-webkit-scrollbar {
    display: none !important;
  }

  .filter-btn {
    flex: 0 0 auto !important;
    scroll-snap-align: start;
    white-space: nowrap !important;
    font-size: 0.82rem !important;
    padding: 0.45rem 1rem !important;
  }

  /* Service & Process Cards */
  .service-card {
    padding: 1.5rem 1.15rem !important;
  }

  .service-icon-box {
    width: 44px !important;
    height: 44px !important;
    font-size: 1.2rem !important;
    margin-bottom: 1rem !important;
  }

  .process-card {
    padding: 1.4rem 1.15rem !important;
  }

  .process-num {
    font-size: 1.85rem !important;
    margin-bottom: 0.75rem !important;
  }

  /* Interactive Viewport Toolbar & Device Switcher */
  .device-switcher-bar {
    width: 100% !important;
    display: flex !important;
    padding: 4px !important;
    gap: 4px !important;
  }

  .device-switcher-btn {
    flex: 1 1 50% !important;
    justify-content: center !important;
    padding: 0.55rem 0.65rem !important;
    font-size: 0.82rem !important;
    gap: 0.4rem !important;
    white-space: nowrap !important;
  }

  .mobile-phone-frame {
    max-width: 290px !important;
    border-radius: 36px !important;
    padding: 8px !important;
    border-width: 2.5px !important;
  }

  .mobile-phone-speaker {
    width: 55px !important;
    height: 14px !important;
    top: 12px !important;
  }

  .mobile-phone-screen {
    border-radius: 26px !important;
  }

  .mobile-metrics-card {
    padding: 1rem !important;
  }

  .mobile-metrics-card .h2 {
    font-size: 1.65rem !important;
  }

  /* Lightbox & Video Player Modals */
  .custom-modal-overlay {
    padding: 0.65rem !important;
  }

  .modal-content-wrap {
    width: 100% !important;
    max-height: 94vh !important;
    border-radius: var(--radius-md) !important;
  }

  .modal-header-bar {
    padding: 0.7rem 0.9rem !important;
  }

  .modal-title-text {
    font-size: 0.92rem !important;
    max-width: 80% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .modal-body-media {
    padding: 0.5rem !important;
  }

  .modal-body-media img {
    max-height: 55vh !important;
    object-fit: contain !important;
  }

  .modal-caption-bar {
    padding: 0.7rem 0.9rem !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.4rem !important;
    font-size: 0.82rem !important;
  }

  .modal-nav-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 1rem !important;
  }

  /* Video Cards */
  .video-card-portrait {
    max-width: 100% !important;
  }

  .video-card-bottom-bar {
    padding: 16px 12px 10px !important;
  }

  .video-card-bottom-bar .video-card-title {
    font-size: 0.88rem !important;
  }

  .video-play-btn-overlay {
    width: 48px !important;
    height: 48px !important;
    font-size: 1.2rem !important;
  }
}

/* Small Handheld Devices (< 576px / 480px / 375px / 320px) */
@media (max-width: 575.98px) {

  /* Container Edge Spacing */
  .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Hero & Section CTAs Stacking */
  .hero-buttons-group,
  .section-py .d-flex.flex-wrap.gap-3:not(.filter-pills-bar) {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.65rem !important;
  }

  .btn-kraft-primary,
  .btn-kraft-outline,
  .btn-kraft-ghost {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
    padding: 0.72rem 1.25rem !important;
    font-size: 0.9rem !important;
    min-height: 44px;
    display: inline-flex !important;
    align-items: center !important;
  }

  .eyebrow {
    font-size: 0.72rem !important;
    padding: 0.25rem 0.65rem !important;
    margin-bottom: 0.75rem !important;
  }

  /* Project Cards on Mobile */
  .project-card {
    border-radius: var(--radius-md) !important;
  }

  .project-card-body {
    padding: 1.15rem 0.95rem !important;
  }

  .project-card-title {
    font-size: 1.12rem !important;
    line-height: 1.3 !important;
  }

  .project-card-desc {
    font-size: 0.84rem !important;
    line-height: 1.55 !important;
    margin-bottom: 0.85rem !important;
  }

  /* Back to Top Button */
  .back-to-top-btn {
    bottom: 16px !important;
    right: 16px !important;
    width: 42px !important;
    height: 42px !important;
    font-size: 1.1rem !important;
  }

  /* Metric Stat Cards in Case Studies, Hero Highlights & SEO */
  .metric-stat-card {
    padding: 0.65rem 0.35rem !important;
  }

  .metric-stat-card .font-monospace,
  .metric-stat-card .h3,
  .metric-stat-card .h4,
  .metric-stat-card .fs-4 {
    font-size: clamp(0.95rem, 3.8vw, 1.35rem) !important;
    white-space: nowrap;
    letter-spacing: -0.02em;
  }

  .metric-stat-card small {
    font-size: clamp(0.68rem, 2.4vw, 0.78rem) !important;
    line-height: 1.25;
    display: block;
    word-break: break-word;
  }

  /* Badge and Header Wrapping on Mobile Project Cards */
  .project-card-body .badge-tag {
    max-width: 100%;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.55rem !important;
  }

  /* Responsive Audit Score Card Progress Bars */
  .progress {
    height: 6px !important;
  }
}

/* Extra Small Phones (<= 360px / 320px) */
@media (max-width: 360px) {
  .container {
    padding-left: 0.65rem !important;
    padding-right: 0.65rem !important;
  }

  .nav-brand-logo img {
    width: 140px !important;
  }

  .site-header {
    height: 60px !important;
  }

  h1,
  .h1,
  .display-4,
  .display-5 {
    font-size: 1.55rem !important;
  }

  h2,
  .h2,
  .display-6 {
    font-size: 1.3rem !important;
  }

  h3,
  .h3 {
    font-size: 1.15rem !important;
  }

  .badge-tag {
    font-size: 0.66rem !important;
    padding: 0.2rem 0.45rem !important;
  }

  .filter-btn {
    font-size: 0.76rem !important;
    padding: 0.38rem 0.75rem !important;
  }

  .metric-stat-card {
    padding: 0.5rem 0.25rem !important;
  }

  .metric-stat-card .font-monospace,
  .metric-stat-card .h3,
  .metric-stat-card .h4,
  .metric-stat-card .fs-4 {
    font-size: 0.88rem !important;
  }

  .metric-stat-card small {
    font-size: 0.64rem !important;
  }
}

/* --------------------------------------------------------------------------
   Short Mobile Screens & Landscape Orientation (e.g. 844x390, max-height: 550px)
   -------------------------------------------------------------------------- */
@media (max-height: 550px) and (orientation: landscape) {
  .section-py {
    padding-top: clamp(1.25rem, 3vw, 2rem) !important;
    padding-bottom: clamp(1.25rem, 3vw, 2rem) !important;
  }

  .site-header {
    height: 60px !important;
  }

  .display-4, .hero-title, h1 {
    font-size: clamp(1.5rem, 5vw, 2.2rem) !important;
    margin-bottom: 0.5rem !important;
  }

  .lead, p.lead {
    font-size: 0.95rem !important;
    margin-bottom: 1rem !important;
  }
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {

  *,
  ::before,
  ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}