/* ==========================================================================
   HEIGHT PERCENTILE CALCULATOR - RESPONSIVE STYLES
   ========================================================================== */

/* Strict Universal Mobile Overflow Containment */
html, body {
  max-width: 100% !important;
  overflow-x: hidden !important;
  width: 100%;
}

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

/* Base Responsive Typography & Containers */
h1, h2, h3, h4, h5, h6, p, li, a, span, label {
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
}

img, svg, picture, video, canvas, figure {
  max-width: 100% !important;
  height: auto;
  box-sizing: border-box;
}

/* Layout Grid Breakpoints */
@media (max-width: 1024px) {
  .layout-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 1.75rem;
  }
  
  .hero-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem;
  }
  
  .hero-visual {
    width: 100% !important;
    max-width: 100% !important;
    justify-self: center;
  }
  
  .sidebar-column {
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 1.5rem;
  }

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

@media (max-width: 768px) {
  :root {
    --header-height: 64px;
  }

  .main-content {
    padding-bottom: 2.5rem;
    max-width: 100%;
    overflow-x: hidden;
  }

  .container {
    padding: 0 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  h1, h1#hero-title {
    font-size: clamp(1.65rem, 5.5vw, 2.15rem) !important;
    line-height: 1.2 !important;
    margin-bottom: 1rem !important;
  }

  h2 {
    font-size: clamp(1.3rem, 4.5vw, 1.6rem) !important;
    line-height: 1.3 !important;
  }

  h3 {
    font-size: clamp(1.1rem, 3.8vw, 1.25rem) !important;
  }

  /* Hero Section */
  .hero-section {
    padding: 1.5rem 0 1.75rem;
    margin-bottom: 1rem;
  }

  .hero-description {
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 100%;
  }

  .hero-tags {
    gap: 0.35rem;
    margin-bottom: 1.25rem;
  }

  .hero-tag {
    font-size: 0.775rem;
    padding: 0.25rem 0.65rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    width: 100%;
  }

  .hero-actions .btn {
    width: 100% !important;
    justify-content: center;
    height: 48px;
  }

  .hero-preview-card {
    padding: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  /* Navigation Mobile Toggle */
  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: #ffffff;
    flex-direction: column;
    align-items: stretch;
    padding: 1.25rem 1.25rem 1.5rem;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    border-bottom: 1px solid var(--border-color);
    transform: translateY(-150%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    visibility: hidden;
    z-index: 999;
  }

  .nav-menu.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .nav-link {
    width: 100%;
    padding: 0.75rem 0.75rem;
    font-size: 1.05rem;
    border-radius: var(--radius-md, 6px);
  }

  .nav-cta-item {
    width: 100%;
    margin-top: 0.5rem;
  }

  .header-cta-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    text-align: center;
    border-radius: var(--radius-md, 8px);
  }

  /* Main Columns & Cards */
  .main-column,
  .sidebar-column,
  .calculator-card,
  .card,
  .educational-content,
  .educational-content section,
  .toc-card,
  .example-calc-box,
  .cta-banner,
  .sidebar-widget {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden;
  }

  .calculator-card,
  .card,
  .educational-content section {
    padding: 1.25rem 1rem !important;
    border-radius: var(--radius-lg);
    margin-bottom: 1.25rem !important;
  }

  /* Form & Inputs */
  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .form-group {
    width: 100% !important;
    max-width: 100% !important;
  }

  .input-row {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 0.6rem !important;
  }

  .input-row > div,
  .input-row > input {
    width: 100% !important;
    max-width: 100% !important;
  }

  .form-label {
    font-size: 0.875rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    width: 100%;
  }

  .form-label .sub-label {
    font-size: 0.775rem;
  }

  .form-input, .form-select {
    height: 46px !important;
    font-size: 0.925rem !important;
    padding: 0 0.75rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .unit-switcher {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
  }

  .unit-btn {
    flex: 1 !important;
    width: 50% !important;
    padding: 0.45rem 0.25rem !important;
    font-size: 0.8rem !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
  }

  .calculator-actions {
    flex-direction: column !important;
    gap: 0.65rem !important;
    width: 100% !important;
  }

  .calculator-actions .btn {
    width: 100% !important;
    height: 48px !important;
    justify-content: center !important;
    font-size: 0.95rem !important;
  }

  /* Result Card & Gauge */
  .result-card {
    padding: 1.25rem 0 0 0;
    width: 100% !important;
    max-width: 100% !important;
  }

  .result-value-big {
    font-size: clamp(2rem, 7.5vw, 2.75rem) !important;
    line-height: 1.15;
  }

  .result-grid-summary {
    grid-template-columns: 1fr !important;
    gap: 0.6rem !important;
    width: 100% !important;
  }

  .summary-box {
    padding: 0.75rem 0.85rem;
    width: 100% !important;
  }

  .percentile-scale-container {
    padding: 0.85rem 0.65rem 0.65rem;
    margin: 1.15rem 0;
    width: 100% !important;
  }

  .percentile-scale-title {
    font-size: 0.68rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }

  .scale-ticks {
    font-size: 0.65rem;
    width: 100%;
  }

  .scale-ticks .hide-mobile {
    display: none;
  }

  /* Tables & Scrollability */
  .table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: block !important;
    margin: 1rem 0 !important;
    border-radius: var(--radius-md);
  }

  .data-table {
    width: 100% !important;
    min-width: 480px !important;
    font-size: 0.825rem !important;
  }

  .data-table th, .data-table td {
    padding: 0.5rem 0.6rem !important;
  }

  /* Educational Text & Headings */
  .educational-content section h2 {
    font-size: 1.3rem !important;
    margin-bottom: 0.75rem !important;
    line-height: 1.3 !important;
  }

  .educational-content section h3 {
    font-size: 1.1rem !important;
    margin-top: 1rem !important;
  }

  .educational-content section p {
    font-size: 0.925rem !important;
    line-height: 1.6 !important;
    margin-bottom: 0.85rem !important;
  }

  .educational-content section li {
    font-size: 0.9rem !important;
    margin-bottom: 0.35rem !important;
  }

  .educational-content section ul,
  .educational-content section ol {
    padding-left: 1.15rem !important;
    margin-bottom: 0.85rem !important;
  }

  /* Infographics & Visual Containers */
  .chart-visual-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 1.15rem 0 !important;
    border-radius: var(--radius-md);
    overflow: hidden !important;
  }

  .responsive-chart-img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    object-fit: contain !important;
  }

  .chart-visual-container figcaption {
    padding: 0.55rem 0.75rem;
    font-size: 0.775rem;
  }

  /* Formula & Code Boxes */
  .formula-box {
    padding: 0.85rem !important;
    margin: 1rem 0 !important;
    width: 100% !important;
  }

  .formula-box .formula-code {
    font-size: 0.8rem !important;
    padding: 0.55rem 0.7rem !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    width: 100% !important;
  }

  /* TOC & FAQs */
  .toc-card {
    padding: 1rem 0.85rem !important;
    margin: 1rem 0 !important;
  }

  .toc-grid {
    grid-template-columns: 1fr !important;
    gap: 0.4rem !important;
  }

  .toc-grid a {
    font-size: 0.875rem !important;
    padding: 0.35rem 0.25rem !important;
  }

  .faq-question {
    padding: 0.85rem 0.9rem !important;
    font-size: 0.925rem !important;
  }

  .faq-answer {
    padding: 0.75rem 0.9rem !important;
    font-size: 0.875rem !important;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 1.75rem !important;
  }

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

  .cta-banner {
    padding: 1.5rem 0.85rem !important;
    margin-top: 1.5rem !important;
    border-radius: var(--radius-md) !important;
  }

  .cta-banner h2 {
    font-size: 1.3rem !important;
  }

  .cta-banner p {
    font-size: 0.875rem !important;
  }

  .sidebar-links {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 0.75rem !important;
  }

  .calculator-card,
  .educational-content section,
  .card {
    padding: 0.9rem 0.75rem !important;
    border-radius: var(--radius-md) !important;
  }

  .unit-btn {
    font-size: 0.775rem !important;
    padding: 0.4rem 0.15rem !important;
  }

  .height-compare-wrapper {
    height: 350px !important;
    padding: 1.75rem 0.35rem 0.5rem !important;
  }

  .figure-img-container {
    width: 95px !important;
    max-width: 32vw !important;
  }
}

@media (max-width: 360px) {
  .container {
    padding: 0 0.5rem !important;
  }

  .hero-preview-card {
    padding: 0.75rem 0.65rem !important;
  }

  .result-value-big {
    font-size: 1.85rem !important;
  }

  .unit-btn {
    font-size: 0.725rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-tag,
  .hero-actions .btn,
  .hero-preview-card {
    transition: none !important;
    transform: none !important;
  }

  .marker-pulse {
    animation: none !important;
  }
}




