/*
 * =============================================================
 * xfact-custom-responsive.css - Responsive overrides for
 * xfact-custom-style.css
 * =============================================================
 * Breakpoints:
 *   @media (max-width: 1024px)  - Tablet
 *   @media (max-width: 768px)   - Large mobile
 *   @media (max-width: 480px)   - Small mobile
 *
 * Contains ONLY overrides - rules that change at a breakpoint.
 * Load AFTER xfact-custom-style.css.
 * =============================================================
 */


/* =============================================================
   Section 2: Layout Containers
   ============================================================= */

@media (max-width: 1024px) {
  .xf-container,
  .xf-page-content {
    padding-left:  var(--space-5);
    padding-right: var(--space-5);
  }
}

@media (max-width: 768px) {
  .xf-container,
  .xf-page-content {
    padding-left:  var(--space-4);
    padding-right: var(--space-4);
  }

  .xf-page-content {
    margin-top:    var(--space-6);
    margin-bottom: var(--space-6);
  }

  /*
   * Section header (xfact-h-container): on mobile the action
   * (button/link) drops to its own row below the heading so
   * neither element gets squeezed.
   */
  .xfact-h-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
  }

  .xfact-h-container h2,
  .xfact-h-container h3,
  .xfact-h-container h4 {
    flex: 1 1 auto;
  }

  .xfact-h-container > *:not(h2):not(h3):not(h4) {
    flex: 0 0 auto;
  }

  /* Keep heading + action on one row; only wrap when they truly can't fit */
  .xfact-h-container--inline {
    display: grid;
    grid-template-columns: 1fr auto;
    flex-wrap: unset;
    align-items: end;
  }

  .xfact-h-container--inline h2,
  .xfact-h-container--inline h3,
  .xfact-h-container--inline h4 {
    flex: unset;
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .xfact-h-container--inline > *:not(h2):not(h3):not(h4) {
    flex: unset;
    grid-column: 2;
    grid-row: 1;
  }
}

@media (max-width: 480px) {
  .xf-container,
  .xf-page-content {
    padding-left:  var(--space-3);
    padding-right: var(--space-3);
  }
}


/* =============================================================
   Section 3: Headings
   ============================================================= */

@media (max-width: 768px) {
  /* H1: remove diagonal clip-path, shrink font */
  .xf-page-title {
    clip-path: none;
    padding-right: var(--space-5);
    font-size: var(--type-size-lg); /* slightly larger font on mobile */
    width: 100%;
  }

  .xf-page-title-bar {
    margin-bottom: var(--space-1);
  }

  .xf-page-subtitle {
    margin-bottom: var(--space-5);
  }
}

@media (max-width: 480px) {
  .xf-page-title {
    font-size: var(--type-size-base);
    padding: var(--space-2) var(--space-4);
  }

  .xf-h2 {
    font-size: var(--type-size-base);
  }

  .xf-h3 {
    font-size: var(--type-size-sm);
    padding: var(--space-1) 0;
  }

  .xf-page-subtitle {
    font-size: var(--type-size-sm);
    margin-bottom: var(--space-4);
  }
}


/* =============================================================
   Section 4: Data Tables
   ============================================================= */

@media (max-width: 768px) {
  /* Bleed the table wrapper edge-to-edge on mobile */
  .xf-table-wrapper {
    border-left:   none;
    border-right:  none;
    border-radius: 0;
    margin: 0 calc(-1 * var(--space-4));
    width: calc(100% + var(--space-8));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .xf-table thead th,
  .xf-table tbody td {
    padding:   var(--space-2) var(--space-3);
    font-size: var(--type-size-xs);
  }
}

@media (max-width: 480px) {
  .xf-table-wrapper {
    margin: 0 calc(-1 * var(--space-3));
    width: calc(100% + var(--space-6));
  }

  /* Force table wider than viewport so overflow-x: auto kicks in */
  .xf-table {
    min-width: 540px;
  }

  .xf-table thead th,
  .xf-table tbody td {
    padding: var(--space-1) var(--space-2);
    white-space: nowrap;
  }

  /* Hide the row-number column to save horizontal space */
  .xf-table__col-no,
  .xf-table__no {
    display: none;
  }
}


/* =============================================================
   Section 7: Filter Panel
   ============================================================= */

@media (max-width: 768px) {
  .xf-filter-panel {
    flex-direction: column;
    align-items:    stretch;
    gap:    var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .xf-filter-panel__fields {
    flex-direction: column;
    gap: var(--space-3);
  }

  .xf-filter-panel .mds-form-group {
    min-width: 0;
  }

  .xf-filter-panel__actions {
    justify-content: stretch;
  }

  .xf-filter-panel__actions .mds-btn {
    width: 100%;
    justify-content: center;
  }
}


/* =============================================================
   Section 8: Topic Cards
   ============================================================= */

/* 3-col → 2-col at mid-tablet */
@media (max-width: 900px) {
  .xf-topic-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 2-col → single column on large mobile */
@media (max-width: 768px) {
  .xf-topic-cards {
    grid-template-columns: 1fr;
  }
}


/* =============================================================
   Section 9: Callout Cards
   ============================================================= */

@media (max-width: 768px) {
  .xf-callout-cards {
    grid-template-columns: 1fr;
  }
}


/* =============================================================
   Section 12: Report Selector / Report Panel Accordion
   ============================================================= */

@media (max-width: 768px) {
  .xf-report-panel__header {
    padding: var(--space-3) var(--space-4);
    gap:     var(--space-3);
  }

  .xf-report-panel__name {
    font-size: var(--type-size-sm);
  }

  /* Truncate long descriptions on mobile to keep headers compact */
  .xf-report-panel__desc {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .xf-report-panel__body {
    padding: var(--space-3) var(--space-4) var(--space-4);
  }

  /* Date-from / date-to stack vertically */
  .xf-report-panel__date-row {
    flex-direction: column;
    gap: var(--space-3);
  }

  /* Username field: drop max-width constraint */
  .xf-report-panel__username-row .mds-form-group {
    max-width: none;
  }

  /* Download action: full-width */
  .xf-report-panel__actions .mds-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .xf-report-selector {
    gap: var(--space-2);
  }

  /* Badge + chevron stack vertically on very small screens */
  .xf-report-panel__right {
    flex-direction: column;
    align-items:    flex-end;
    gap: var(--space-1);
  }

  .xf-report-panel__badge {
    font-size: 0.625rem;
  }

  /* Desc fully hidden at 480px */
  .xf-report-panel__desc {
    display: none;
  }
}


/* =============================================================
   Filter Group Accordion / Required Section
   ============================================================= */

@media (max-width: 768px) {
  .cjis-filter-group .mds-details-toggle__content {
    padding: var(--space-4) var(--space-3);
  }
}

@media (max-width: 480px) {
  .cjis-required-section {
    padding: var(--space-4);
  }
}
