/**
 * ToolFlux Lab - Master Responsive & RTL Adaptive Design System
 * Ensures seamless, non-overflowing UX from 320px up to 1920px+
 */

/* =========================================================
   MOBILE & TABLET BREAKPOINTS (320px - 640px)
========================================================= */
@media (max-width: 640px) {
  :root {
    --header-height: 60px;
  }

  /* Accessible Touch Targets for Mobile Header */
  .header-inner {
    gap: 8px;
  }

  .brand {
    gap: 8px;
    min-height: 44px;
  }

  .brand-name {
    font-size: 0.9375rem;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 0.8125rem;
  }

  .header-actions {
    gap: 6px;
  }

  .lang-toggle {
    padding: 0 8px;
    height: 40px;
    min-height: 40px;
    font-size: 12px;
    box-sizing: border-box;
  }

  .btn-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    box-sizing: border-box;
  }

  .header-search-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    justify-content: center;
    box-sizing: border-box;
  }

  .header-search-btn span,
  .header-search-btn .kbd-badge {
    display: none;
  }

  /* Hero Section Fluid Mobile Typography & Rhythm */
  .hero-section {
    padding-block: var(--space-6) var(--space-6);
  }

  .hero-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    margin-bottom: var(--space-3);
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .hero-title {
    font-size: clamp(1.625rem, 6vw, 2.25rem);
    line-height: 1.25;
    margin-bottom: var(--space-2);
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .hero-subtitle {
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: var(--space-4);
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .hero-search-wrapper {
    width: 100%;
    max-width: 100%;
  }

  .hero-search-bar {
    padding: 8px 12px;
    min-height: 44px;
    box-sizing: border-box;
    width: 100%;
  }

  .hero-search-input {
    font-size: 0.875rem;
    min-width: 0;
  }

  /* Full-width Stacked Mobile Flagship Action Buttons */
  .hero-flagship-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
    margin-top: var(--space-4);
    margin-bottom: var(--space-3);
    box-sizing: border-box;
  }

  .hero-flagship-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
    min-height: 44px;
    font-size: 0.875rem;
    box-sizing: border-box;
  }

  .hero-quick-tools {
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
  }

  .quick-tool-link {
    font-size: 0.75rem;
    padding: 4px 10px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
  }

  /* Card and Studio Padding on Mobile */
  .studio-card,
  .tool-card,
  .category-card,
  .why-card,
  .workspace-card,
  .card {
    padding: var(--space-4) !important;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .studio-subtool-pill {
    font-size: 0.75rem;
    padding: 5px 9px;
    min-height: 32px;
    box-sizing: border-box;
  }

  .results-hub-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .result-hero-value {
    font-size: 2rem;
    word-break: break-all;
  }

  .segmented-tabs .tab-btn {
    min-width: 100%;
    text-align: center;
    min-height: 44px;
  }

  .workspace-actions {
    flex-direction: column;
    width: 100%;
  }

  .workspace-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  /* Grid reflows on mobile */
  .tools-grid,
  .categories-grid,
  .why-grid,
  .features-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

/* =========================================================
   EXTRA-COMPACT MOBILE BREAKPOINTS (320px - 380px)
========================================================= */
@media (max-width: 380px) {
  .tf-container {
    padding-inline: 12px;
  }

  .brand-name {
    font-size: 0.875rem;
  }

  .brand-tag {
    display: none;
  }

  .hero-badge {
    font-size: 0.6875rem;
    padding: 4px 8px;
    line-height: 1.3;
  }

  .studio-card,
  .tool-card,
  .category-card,
  .why-card,
  .card {
    padding: 12px !important;
  }

  .studio-subtool-pill {
    font-size: 0.6875rem;
    padding: 3px 6px;
  }
}

/* =========================================================
   RTL SPECIFIC OVERRIDES & LOGICAL PROPERTIES
========================================================= */
html[dir="rtl"] {
  text-align: start;
}

html[dir="rtl"] .hero-title {
  letter-spacing: 0;
}

html[dir="rtl"] .kbd-badge {
  direction: ltr;
}

html[dir="rtl"] .formula-box {
  direction: ltr;
  text-align: left;
}

html[dir="rtl"] .result-hero-value {
  letter-spacing: 0;
}
