/* ============================================================
   法小帮 (LawXB) - Mobile-first Responsive Stylesheet
   ------------------------------------------------------------
   Strategy:
   - Base (mobile-first) rules apply at any width.
   - Tablet rules kick in at min-width: 768px (--bp-md).
   - Desktop rules kick in at min-width: 1024px (--bp-lg).
   - Rules are GENERIC and additive. They shape the shared
     .lawxb-* utility classes and the cross-page navigation
     shell (.spatial-header / .nav-cluster-* / .site-menu-dropdown)
     WITHOUT overriding page-specific layouts or colors.
   - !important is avoided unless overriding an inline-style or
     a high-specificity page rule that would otherwise break the
     mobile layout. Existing page styles are NOT touched.
   ============================================================ */

/* ============================================================
   Base (mobile, < 768px) — defaults
   ============================================================ */

/* Tighter horizontal padding on small screens so content can
   breathe without overflowing. Restored at desktop. */
.lawxb-container {
  padding-inline: var(--lawxb-space-3);
}

/* Cards: stack vertically by default; gap tightened. */
.lawxb-grid {
  grid-template-columns: 1fr;
  gap: var(--lawxb-space-3);
}

/* Buttons span full width on mobile for reliable tap targets. */
.lawxb-btn {
  width: 100%;
}

/* Inline badges and inputs keep their natural sizing. */
.lawxb-input {
  font-size: var(--lawxb-font-size-base);  /* prevent iOS zoom-on-focus */
}

/* ---- Cross-page navigation shell ----
   The site header uses .spatial-header with two nav clusters and
   a "菜单" toggle (.header-link-btn#menuToggle). Keep page-specific
   dropdown positioning/z-index intact so desktop home menu remains clickable. */
.spatial-header .nav-cluster-left,
.spatial-header .nav-cluster-right {
  gap: var(--lawxb-space-3);
}

/* Ensure the menu toggle is a comfortable tap target on mobile. */
.header-link-btn#menuToggle {
  min-height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Body-level helpers when the mobile menu is open: prevent
   background scroll. Pages already toggle the .menu-open class. */
body.menu-open {
  overflow: hidden;
}

/* ---- Typography scaling (mobile baseline) ----
   Apply to elements that opt into the design-system type scale.
   Page-specific headings are NOT affected. */
.lawxb-h1 { font-size: var(--lawxb-font-size-xl); line-height: var(--lawxb-line-height-tight); }
.lawxb-h2 { font-size: var(--lawxb-font-size-lg); line-height: var(--lawxb-line-height-tight); }
.lawxb-h3 { font-size: var(--lawxb-font-size-md); line-height: var(--lawxb-line-height-base); }
.lawxb-lead { font-size: var(--lawxb-font-size-md); line-height: var(--lawxb-line-height-relaxed); }
.lawxb-small { font-size: var(--lawxb-font-size-sm); }

/* Reduce default heading sizes on mobile for opted-in elements. */
.lawxb-h1 { font-size: var(--lawxb-font-size-lg); }

/* ---- Section spacing (mobile) ----
   Tighter vertical rhythm on mobile. */
.lawxb-section {
  padding-block: var(--lawxb-space-6);
}
.lawxb-stack > * + * {
  margin-top: var(--lawxb-space-3);
}

/* ============================================================
   Tablet (>= 768px)
   ============================================================ */
@media (min-width: 768px) {
  /* Container gets standard padding. */
  .lawxb-container {
    padding-inline: var(--lawxb-space-4);
  }

  /* Two-column grid where content typically pairs up. */
  .lawxb-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--lawxb-space-4);
  }

  /* Buttons revert to inline auto width. */
  .lawxb-btn {
    width: auto;
  }

  /* Type scale steps up one notch. */
  .lawxb-h1 { font-size: var(--lawxb-font-size-xl); }
  .lawxb-h2 { font-size: var(--lawxb-font-size-lg); }
  .lawxb-h3 { font-size: var(--lawxb-font-size-md); }

  /* Section breathing room increases. */
  .lawxb-section {
    padding-block: var(--lawxb-space-8);
  }
  .lawxb-stack > * + * {
    margin-top: var(--lawxb-space-4);
  }
}

/* ============================================================
   Desktop (>= 1024px)
   ============================================================ */
@media (min-width: 1024px) {
  /* Container uses full max-width. */
  .lawxb-container {
    padding-inline: var(--lawxb-space-5);
  }

  /* Three-column grid for denser dashboards/listings.
     Authors can override with inline --cols. */
  .lawxb-grid {
    grid-template-columns: repeat(var(--cols, 3), 1fr);
    gap: var(--lawxb-space-5);
  }

  /* Type scale reaches full size. */
  .lawxb-h1 { font-size: var(--lawxb-font-size-2xl); }
  .lawxb-h2 { font-size: var(--lawxb-font-size-xl); }
  .lawxb-h3 { font-size: var(--lawxb-font-size-lg); }

  /* Full section spacing on desktop. */
  .lawxb-section {
    padding-block: var(--lawxb-space-12);
  }
  .lawxb-stack > * + * {
    margin-top: var(--lawxb-space-5);
  }

  /* On desktop, the full nav clusters are always visible and the
     menu toggle remains available for the mega-dropdown. Nothing
     is forced here — this block exists to document intent and
     keep the cascade explicit. */
}

/* ============================================================
   Wide desktop (>= 1280px) — subtle refinement only
   ============================================================ */
@media (min-width: 1280px) {
  .lawxb-h1 { font-size: var(--lawxb-font-size-3xl); }
}

/* ============================================================
   Reduced motion — respect user preference
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .lawxb-btn,
  .lawxb-input {
    transition: none;
  }
}
