/* DensityGuard Global Responsive Overrides (v5) 
   Nuclear Edition: Absolute Zero Overlap 
   Using Block Layout + Extreme Specificity to override persistent grid remnants. */

@media (max-width: 1180px) {

  /* 1. NUCLEAR RESET FOR HEADERS */
  html body .section-heading,
  html body .faq-board-head,
  html body .scanner-shell-header,
  html body .scanner-meta {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    grid-template-columns: none !important;
    grid-template-areas: none !important;
    margin-bottom: 2.5rem !important;
    position: relative !important;
  }

  /* 2. FORCE CHILDREN TO BE BLOCK & FULL-WIDTH */
  html body .section-heading>div,
  html body .section-heading>p,
  html body .section-heading>article,
  html body .faq-board-head>div,
  html body .faq-board-head>p,
  html body .scanner-meta-primary,
  html body .scanner-meta-secondary {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 0 1rem 0 !important;
    /* Forces vertical separation */
    padding: 0 !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    float: none !important;
    clear: both !important;
  }

  /* Specific fix for the hidden 'div' wrapper around h1 in scanner/changelog */
  html body .section-heading div {
    width: 100% !important;
    max-width: none !important;
    display: block !important;
  }

  /* Ensure description is pushed down */
  html body .section-desc {
    margin-top: 1.5rem !important;
    opacity: 1 !important;
    visibility: visible !important;
    line-height: 1.6 !important;
  }

  html body.scanner-page .section-heading .scanner-title-group {
    display: flex !important;
    width: 100% !important;
  }

  html body.scanner-page .section-heading .scanner-exchange-line {
    display: grid !important;
  }
}

@media (max-width: 720px) {

  /* 3. FLUID TYPOGRAPHY RESET */
  html body .display-lg {
    font-size: clamp(1.85rem, 8vw, 2.7rem) !important;
    line-height: 1.2 !important;
    width: 100% !important;
    max-width: none !important;
    display: block !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    margin-bottom: 0.5rem !important;
  }

  html body .headline-md {
    font-size: clamp(1.5rem, 7vw, 2.1rem) !important;
    line-height: 1.25 !important;
    width: 100% !important;
    max-width: none !important;
    display: block !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  /* 4. COMPONENT NUCLEAR RESETS */

  /* FAQ Orbit */
  html body .faq-orbit {
    transform: scale(0.65) !important;
    margin: 3rem auto !important;
  }

  /* Scanner Toolbar */
  html body .scanner-toolbar {
    display: block !important;
    width: 100% !important;
  }

  html body .scanner-control {
    display: block !important;
    width: 100% !important;
    margin-bottom: 1.25rem !important;
  }

  html body .scanner-control select,
  html body .scanner-control input {
    width: 100% !important;
    display: block !important;
  }

  html body .scanner-refresh-button {
    width: 100% !important;
    margin-top: 1rem !important;
  }

  html body.scanner-page .section-heading .scanner-title-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.85rem !important;
  }

  html body.scanner-page .section-heading .scanner-exchange-line {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  /* Changelog Entries */
  html body .changelog-container {
    padding-left: 0 !important;
  }

  html body .changelog-container::before {
    display: none !important;
  }

  html body .changelog-entry {
    display: block !important;
    padding-left: 0 !important;
    margin-bottom: 3rem !important;
  }

  html body .changelog-entry::before {
    display: none !important;
    /* Hide vertical line on narrow screens to save space if needed */
  }

  html body .changelog-entry::after {
    display: none !important;
  }

  html body .version-badge {
    max-width: 100% !important;
    flex-wrap: wrap !important;
  }

  html body .version-date {
    margin-left: 0.5rem !important;
  }

  html body .changelog-card {
    padding: 1.5rem !important;
  }
}

@media (max-width: 480px) {
  html body .section-block {
    padding-top: 2.5rem !important;
  }

  /* 5. STANDARDIZE HEADER SPACING (Match Landing) */
  html body :is(.scanner-page, .faq-page, .profile-page) .main-content {
    padding-top: 0 !important;
  }

  html body .scanner-page-intro {
    padding-top: 0.25rem !important;
    margin-top: -1.25rem !important;
  }

  html body .scanner-page-heading {
    margin-bottom: 0 !important;
  }

  html body .scanner-page-heading .headline-md {
    margin-top: 0.15rem !important;
  }

  html body .scanner-intro-chips {
    margin-top: 0.1rem !important;
  }

  html body .faq-hero-section {
    padding-top: 0.25rem !important;
    margin-top: -1rem !important;
  }

  html body .docs-main {
    padding-top: 0 !important;
    margin-top: -0.5rem !important;
  }

  html body .changelog-container {
    margin-top: 0 !important;
  }

  /* Docs Chips Fix */
  html body .docs-chip-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  html body .docs-chip {
    width: auto !important;
    max-width: 100% !important;
    white-space: normal !important;
    word-break: break-word !important;
    text-align: center !important;
    justify-content: center !important;
    padding: 0.6rem 0.85rem !important;
    font-size: 0.8rem !important;
    height: auto !important;
  }

  html body .section-block {
    padding-top: 1.25rem !important;
  }
}
