/* Responsive hardening for the research/result workspace. */
.results-pane,
.results-toolbar,
.results-toolbar > div,
.result-heading-row,
.active-filters,
.entry-list,
.entry-card,
.entry-card-head,
.entry-card-head > div:first-child {
  min-width: 0;
}

.entry-card {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.entry-card-head > div:first-child {
  flex: 1 1 auto;
}

.entry-card h2,
.entry-preview,
.entry-card-meta,
.filter-chip,
.mini-tag {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.entry-signals {
  flex: 0 0 auto;
}

/* Give the result list more room on tablet/small laptop widths by turning
   the detail column into an overlay earlier than before. */
@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .detail-pane {
    position: fixed;
    right: 0;
    top: 72px;
    width: min(520px, 92vw);
    z-index: 15;
    box-shadow: -18px 0 44px rgba(24,34,48,.14);
    transform: translateX(102%);
    transition: .2s ease;
  }

  .detail-pane.open {
    transform: translateX(0);
  }

  .detail-close-mobile {
    display: inline-grid !important;
  }

  .results-toolbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .results-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .results-toolbar > div:first-child,
  .sort-wrap,
  .compact-select {
    width: 100%;
    max-width: none;
  }

  .result-heading-row {
    flex-wrap: wrap;
  }

  .sort-wrap {
    display: flex;
  }

  .entry-card-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .entry-card-meta {
    max-width: 100%;
  }

  .entry-signals {
    align-self: start;
  }

  /* Mobile filter drawer: keep its controls inside the visible iPhone
     viewport and block taps from reaching the result cards underneath. */
  .sidebar {
    top: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
    z-index: 50;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar::after {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    left: min(320px, 88vw);
    right: 0;
    background: rgba(16,24,40,.38);
    pointer-events: auto;
  }

  .sidebar-mobile-head {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #fff;
    padding: 2px 0 10px;
  }

  .sidebar-mobile-head .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* iOS Safari: use the dynamic visual viewport rather than 100vh, which
     can extend behind the browser chrome. Safe-area padding protects the
     close control and the final content around notches/home indicator. */
  .detail-pane {
    top: 0;
    bottom: auto;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    z-index: 40;
  }

  .detail-content {
    padding-top: max(20px, env(safe-area-inset-top));
    padding-right: max(18px, env(safe-area-inset-right));
    padding-bottom: max(44px, calc(env(safe-area-inset-bottom) + 24px));
    padding-left: max(18px, env(safe-area-inset-left));
  }

  .detail-topline {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #fff;
    padding-top: 4px;
    padding-bottom: 10px;
  }

  .detail-close-mobile {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .entry-card-head {
    grid-template-columns: 1fr;
  }

  .entry-signals {
    justify-content: flex-start;
  }

  .entry-card h2 {
    font-size: 14px;
  }

  .entry-preview {
    font-size: 12.5px;
  }
}
