/* ==========================================================================
   TheToolMint - Master Responsive Stylesheet
   Mobile-First & Fluid Breakpoint Architecture (320px to 1920px+)
   100% Zero-Overflow & High-Precision Touch Optimization
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Global Zero-Overflow & Element Constraints
   -------------------------------------------------------------------------- */
html,
body {
  overflow-x: clip !important;
  max-width: 100vw;
  width: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

pre,
code,
kbd,
samp {
  max-width: 100%;
  overflow-x: auto;
  word-break: break-word;
}

table {
  width: 100%;
  max-width: 100%;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   1. Large Desktop & High-Resolution Displays (>= 1280px)
   -------------------------------------------------------------------------- */
@media (min-width: 1280px) {
  .tools-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.25rem;
  }

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

@media (min-width: 1440px) {
  :root {
    --max-width: 1320px;
  }
}

/* --------------------------------------------------------------------------
   2. Standard Desktop & Small Laptops (993px - 1279px)
   -------------------------------------------------------------------------- */
@media (max-width: 1279px) and (min-width: 993px) {
  .tools-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.15rem;
  }

  .categories-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.15rem;
  }
}

/* --------------------------------------------------------------------------
   3. Tablet & Small Screens (<= 992px)
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .site-header {
    height: auto;
    padding: 0.65rem 0;
  }

  .header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
  }

  .header-search {
    order: 3;
    width: 100%;
    max-width: 100%;
  }

  .header-search-shortcut {
    display: none;
  }

  .header-nav {
    display: none;
  }

  .header-nav.mobile-active {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    gap: 0.85rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    z-index: 1000;
  }

  [data-theme="dark"] .header-nav.mobile-active {
    background: #111827;
    border-bottom-color: #1f2937;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  }

  .mobile-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .mobile-nav-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
  }

  .tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.15rem;
  }

  .categories-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.15rem;
  }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
  }

  .footer-brand {
    grid-column: span 2;
  }
}

/* --------------------------------------------------------------------------
   4. Phablets & Mobile Landscape (<= 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .hero-wrapper {
    padding: 3.25rem 0 1.75rem;
    overflow: hidden;
  }

  .hero-badge {
    max-width: 100%;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
    padding: 0.38rem 0.85rem;
    font-size: 0.78rem;
  }

  .hero-subtitle {
    margin-bottom: 1.75rem;
    padding: 0 0.25rem;
  }

  .hero-category-pills {
    gap: 0.45rem;
    padding: 0 0.25rem;
  }

  .hero-pill-link {
    font-size: 0.78rem;
    padding: 0.35rem 0.75rem;
  }

  .tool-workspace {
    padding: 1.25rem 1rem;
    border-radius: 14px;
  }

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

  .footer-brand {
    grid-column: span 1;
  }

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

  .dropzone {
    padding: 2rem 1rem;
  }

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

/* --------------------------------------------------------------------------
   5. Standard Smartphones (<= 640px)
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .tools-grid {
    grid-template-columns: 1fr;
    gap: 0.95rem;
  }

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

  .tool-card {
    padding: 1.15rem 1rem 0.9rem;
    border-radius: 12px;
  }

  .tool-card-title {
    font-size: 1rem;
  }

  .tool-card-desc {
    font-size: 0.82rem;
  }

  /* Hero Live Sandbox Mobile Adaptation */
  .hero-sandbox-container {
    border-radius: 16px;
    margin-top: 1.75rem;
  }

  .hero-sandbox-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
  }

  .hero-sandbox-tabs {
    width: 100%;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.35rem;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .hero-sandbox-tabs::-webkit-scrollbar {
    display: none;
  }

  .hero-sandbox-tab {
    flex-shrink: 0;
    font-size: 0.74rem;
    padding: 0.32rem 0.65rem;
    white-space: nowrap;
  }

  .hero-sandbox-chip {
    font-size: 0.68rem;
    justify-content: center;
    width: 100%;
  }

  .hero-sandbox-panel {
    padding: 0.95rem 0.75rem;
  }

  .sandbox-metrics-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .sandbox-deep-link {
    margin-left: 0;
    width: 100%;
    justify-content: center;
    padding: 0.4rem 0.75rem;
  }

  .sandbox-hash-result-wrap {
    max-width: 100%;
    width: 100%;
    font-size: 0.75rem;
    word-break: break-all;
  }

  /* Floating Engagement Card Mobile Dock */
  .engagement-card {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    border-radius: 14px;
    padding: 0.85rem 1rem;
    transform: translateY(120%) scale(0.95);
  }

  .engagement-card.is-visible {
    transform: translateY(0) scale(1);
  }

  .engagement-card.is-closing {
    transform: translateY(120%) scale(0.95);
  }

  .engagement-card-actions {
    display: flex;
    gap: 0.5rem;
  }

  .engagement-action-pill {
    flex: 1;
    min-height: 42px;
    font-size: 0.8rem;
    padding: 0.5rem 0.5rem;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   6. Compact Mobile (<= 480px / 414px / 390px / 375px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .hero-search-input {
    height: 52px;
    font-size: 0.92rem;
    padding: 0 2.75rem 0 2.75rem;
    border-radius: 14px;
  }

  .hero-search-icon {
    left: 0.85rem;
  }

  .hero-search-hint {
    display: none;
  }

  .btn-group-responsive {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }

  .btn-group-responsive .btn {
    width: 100%;
    min-height: 44px;
  }

  .modal-dialog {
    padding: 1.25rem 1rem;
  }

  .cta-banner {
    padding: 2rem 1rem;
    border-radius: 16px;
  }
}

/* --------------------------------------------------------------------------
   7. Ultra-Compact Mobile Screens (<= 360px / 320px)
   -------------------------------------------------------------------------- */
@media (max-width: 360px) {
  .container {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .brand-logo {
    font-size: 1.15rem;
    gap: 0.45rem;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .brand-icon svg {
    width: 20px;
    height: 20px;
  }

  .brand-name {
    display: inline-block;
    font-size: 1.12rem;
  }

  .hero-title {
    font-size: 1.6rem;
    line-height: 1.2;
  }

  .hero-badge {
    font-size: 0.74rem;
    padding: 0.35rem 0.65rem;
  }

  .hero-pill-link {
    font-size: 0.72rem;
    padding: 0.3rem 0.55rem;
    gap: 0.3rem;
  }

  .hero-search-input {
    height: 48px;
    font-size: 0.86rem;
    padding: 0 2.25rem 0 2.25rem;
  }

  .tool-card {
    padding: 1rem 0.85rem 0.8rem;
  }

  .tool-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .engagement-action-pill span {
    font-size: 0.74rem;
  }
}
