/* 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-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: var(--section-heading-content-gap) !important;
    position: relative !important;
  }

  /* 2. FORCE CHILDREN TO BE BLOCK & FULL-WIDTH */
  html body:not(.scanner-page) .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 !important;
    padding: 0 !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    float: none !important;
    clear: both !important;
  }

  html body .section-heading > * + *,
  html body .faq-board-head > * + * {
    margin-top: var(--section-heading-stack-gap) !important;
  }

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

  /* Ensure description is pushed down */
  html body .section-desc {
    margin-top: var(--section-heading-stack-gap) !important;
    opacity: 1 !important;
    visibility: visible !important;
    line-height: 1.6 !important;
  }

  html body.scanner-page .section-heading .scanner-title-group {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: clamp(1rem, 2.4vw, 1.8rem) !important;
    width: 100% !important;
  }

  html body.scanner-page .section-heading .scanner-title-copy {
    flex: 0 0 auto !important;
    width: max-content !important;
    min-width: 0 !important;
  }

  html body.scanner-page .section-heading .scanner-heading-title {
    display: flex !important;
    align-items: center !important;
    gap: 0.8rem !important;
    width: auto !important;
    margin-top: var(--section-kicker-title-gap) !important;
  }

  html body.scanner-page .section-heading .scanner-heading-title .headline-md {
    white-space: nowrap !important;
  }

  html body.scanner-page .section-heading .scanner-exchange-line {
    display: grid !important;
    flex: 1 1 auto !important;
    width: auto !important;
    min-height: clamp(5.8rem, 10vw, 7rem) !important;
    margin-top: 0 !important;
    grid-template-columns: repeat(4, minmax(3rem, 1fr)) !important;
    gap: clamp(0.45rem, 1vw, 0.7rem) !important;
  }
}

@media (min-width: 721px) and (max-width: 960px) {
  html body.scanner-page .section-heading .scanner-title-group {
    display: block !important;
  }

  html body.scanner-page .section-heading .scanner-title-copy {
    flex-basis: auto !important;
    width: auto !important;
  }

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

@media (max-width: 720px) {

  /* 3. FLUID TYPOGRAPHY RESET */
  html body .display-lg {
    font-size: clamp(1.5rem, 7vw, 2.05rem) !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.35rem, 5.5vw, 1.7rem) !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;
  }

  html body .scanner-heading-title .headline-md {
    display: inline-block !important;
    width: auto !important;
  }

  html body .scanner-info-button {
    margin-left: 1.25rem !important;
  }

  html body.scanner-page .section-heading .scanner-exchange-line {
    display: none !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-toolbar-group .scanner-control {
    display: grid !important;
    margin-bottom: 0 !important;
  }

  html body .scanner-toolbar-group .scanner-refresh-button {
    margin-top: 0 !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: none !important;
  }

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

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

  html body .changelog-entry {
    display: grid !important;
    gap: 0.75rem !important;
    padding-left: 0 !important;
    margin-bottom: 0 !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;
  }
}

/* Prevent dot shadow cropping by disabling content-visibility paint containment on all screen sizes */
html body.landing .section-block,
html body.scanner-page .section-block,
html body.faq-page .section-block,
html body.changelog-page .section-block,
html body.detail-page .section-block {
  content-visibility: visible !important;
  contain: none !important;
}

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

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

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

  html body .scanner-page-heading .headline-md {
    margin-top: var(--section-kicker-title-gap) !important;
  }

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

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

  html body .docs-main {
    padding-top: var(--page-header-content-gap) !important;
    margin-top: 0 !important;
  }

  html body :is(.scanner-page, .faq-page, .changelog-page, .detail-page) .site-footer {
    margin-top: var(--page-header-content-gap) !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: var(--section-block-gap) !important;
  }

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

  html body.changelog-page .changelog-feed-section {
    margin-top: 0 !important;
  }
}
