/*
 * Shared Danbooru-style listing surfaces.
 * Keep public index pages quiet and consistent: search, paginator, results.
 */

:root {
  --emalm-listing-border: #d8d8d8;
  --emalm-listing-border-soft: #e6e6e6;
  --emalm-listing-panel: #fff;
  --emalm-listing-panel-muted: transparent;
  --emalm-listing-row-alt: transparent;
  --emalm-listing-row-hover: #fff8bf;
  --emalm-listing-muted: #666;
  --emalm-listing-focus: #D4AF37;
}

#page.emalm-listing-page,
.emalm-listing-page {
  background: transparent !important;
  border: 0;
  box-shadow: none;
  margin: 18px 24px 32px;
  max-width: 1280px;
  min-width: 0;
}

.emalm-static-layout .left.emalm-listing-page,
body > main.left.emalm-listing-page,
body > section.left.emalm-listing-page {
  background: transparent !important;
}

.album-page-shell,
body > .left:has(.emalm-listing-page) {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.emalm-listing-page .emalm-listing-heading {
  margin: 0 0 16px;
}

.emalm-listing-page .emalm-listing-summary {
  color: var(--emalm-listing-muted);
  margin: -8px 0 18px;
}

.simple_form.search-form.inline-form.emalm-search-form,
form.search-form.inline-form.emalm-search-form,
.emalm-search-form {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  display: grid;
  gap: 8px 12px;
  grid-template-columns: max-content minmax(180px, 360px);
  justify-content: start;
  margin: 0 0 18px;
  max-width: 760px;
  padding: 0;
}

.emalm-search-form > input[type="hidden"] {
  display: none;
}

.emalm-search-form .input,
.emalm-search-form .emalm-search-field {
  display: contents;
  margin: 0;
  position: relative;
}

.emalm-search-form label {
  align-self: center;
  color: #555;
  font-size: 12px;
  font-weight: 700;
  grid-column: 1;
  justify-self: end;
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

.emalm-search-form input[type="text"],
.emalm-search-form input[type="search"],
.emalm-search-form input[type="date"],
.emalm-search-form input[type="number"],
.emalm-search-form input:not([type]),
.emalm-search-form select,
.emalm-search-form textarea {
  border: 1px solid var(--emalm-listing-border);
  border-radius: 4px;
  box-sizing: border-box;
  grid-column: 2;
  min-height: 30px;
  min-width: 0;
  padding: 5px 8px;
  width: 100%;
}

.emalm-search-form textarea {
  min-height: 92px;
  resize: vertical;
}

.emalm-search-form .checkbox,
.emalm-search-form .boolean,
.emalm-search-form .emalm-search-checkbox {
  align-items: center;
  display: flex;
  gap: 6px;
  grid-column: 2;
}

.emalm-search-form .checkbox label,
.emalm-search-form .boolean label,
.emalm-search-form .emalm-search-checkbox label {
  display: contents;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
}

.emalm-search-form input[type="checkbox"] {
  margin: 0;
}

.emalm-search-form input[type="submit"],
.emalm-search-form button[type="submit"],
.emalm-search-submit {
  grid-column: 2;
  justify-self: start;
  min-height: 30px;
}

.emalm-search-form .emalm-comment-autocomplete,
.emalm-search-form .emalm-resource-autocomplete,
.emalm-search-form .emalm-artist-autocomplete {
  grid-column: 2;
  left: auto;
  right: auto;
  width: min(360px, 100%);
}

.emalm-search-form .emalm-search-autocomplete-anchor {
  display: block;
  grid-column: 2;
  min-width: 0;
  position: relative;
  width: 100%;
}

.emalm-search-form .emalm-search-autocomplete-anchor > input {
  width: 100%;
}

.emalm-search-form .emalm-search-autocomplete-anchor > .emalm-comment-autocomplete,
.emalm-search-form .emalm-search-autocomplete-anchor > .emalm-resource-autocomplete,
.emalm-search-form .emalm-search-autocomplete-anchor > .emalm-artist-autocomplete,
.emalm-search-form .emalm-search-autocomplete-anchor > .emalm-home-topbar-search-suggestions {
  left: 0;
  min-width: 100%;
  right: 0;
  width: auto;
}

.paginator.numbered-paginator,
.emalm-listing-paginator,
.emalm-activity-pagination,
.emalm-artist-paginator {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 18px 0;
}

.paginator.numbered-paginator a,
.paginator.numbered-paginator span,
.emalm-listing-paginator a,
.emalm-listing-paginator span,
.emalm-activity-pagination a,
.emalm-activity-pagination span,
.emalm-artist-paginator a,
.emalm-artist-paginator span {
  background: #fff;
  border: 1px solid var(--emalm-listing-border);
  border-radius: 6px;
  color: inherit;
  display: inline-flex;
  min-width: 30px;
  padding: 4px 8px;
  text-align: center;
  text-decoration: none;
}

.paginator.numbered-paginator a:hover,
.emalm-listing-paginator a:hover,
.emalm-activity-pagination a:hover,
.emalm-artist-paginator a:hover {
  background: var(--emalm-listing-focus);
  text-decoration: none;
}

.paginator-current,
.emalm-listing-current {
  font-weight: 700;
}

.paginator-prev[rel="prev"]:not(a),
.paginator-next[rel="next"]:not(a),
.emalm-listing-paginator .is-disabled {
  color: #999;
}

.emalm-table-wrap,
.emalm-activity-table-wrap {
  overflow-x: auto;
}

table.striped,
table.emalm-table,
.emalm-activity-table,
.moderator-dashboard-table,
.favorite-groups-table {
  background: #fff;
  border-collapse: collapse;
  width: 100%;
}

#page table:not(.emalm-table-no-style),
main.emalm-static-page table:not(.emalm-table-no-style) {
  background: #fff;
  border-collapse: collapse;
}

table.striped th,
table.striped td,
table.emalm-table th,
table.emalm-table td,
.emalm-activity-table th,
.emalm-activity-table td,
.moderator-dashboard-table th,
.moderator-dashboard-table td,
.favorite-groups-table th,
.favorite-groups-table td,
#page table:not(.emalm-table-no-style) th,
#page table:not(.emalm-table-no-style) td,
main.emalm-static-page table:not(.emalm-table-no-style) th,
main.emalm-static-page table:not(.emalm-table-no-style) td {
  border-top: 1px solid var(--emalm-listing-border-soft);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

table.striped th,
table.emalm-table th,
.emalm-activity-table th,
.moderator-dashboard-table th,
.favorite-groups-table th,
#page table:not(.emalm-table-no-style) th,
main.emalm-static-page table:not(.emalm-table-no-style) th {
  background: var(--emalm-listing-panel-muted);
  font-weight: 700;
  white-space: nowrap;
}

table.striped tbody tr:nth-child(even),
table.emalm-table tbody tr:nth-child(even),
.emalm-activity-table tbody tr:nth-child(even),
.moderator-dashboard-table tbody tr:nth-child(even),
.favorite-groups-table tbody tr:nth-child(even),
#page table:not(.emalm-table-no-style) tbody tr:nth-child(even),
main.emalm-static-page table:not(.emalm-table-no-style) tbody tr:nth-child(even) {
  background: var(--emalm-listing-row-alt);
}

table.striped tbody tr:hover,
table.emalm-table tbody tr:hover,
.emalm-activity-table tbody tr:hover,
.moderator-dashboard-table tbody tr:hover,
.favorite-groups-table tbody tr:hover,
#page table:not(.emalm-table-no-style) tbody tr:hover,
main.emalm-static-page table:not(.emalm-table-no-style) tbody tr:hover {
  background: var(--emalm-listing-row-hover);
}

table.autofit {
  table-layout: auto;
}

.col-expand {
  width: 100%;
}

.emalm-listing-empty,
.emalm-activity-empty,
.emalm-activity-admin-only {
  background: #fff9d7;
  border: 1px solid #ead79a;
  border-radius: 8px;
  padding: 14px 16px;
}

.fineprint,
.emalm-listing-muted,
.emalm-activity-muted,
.emalm-artist-muted {
  color: var(--emalm-listing-muted);
  font-size: 12px;
}

.post-count,
.count {
  color: #777;
  font-size: 12px;
  margin-left: 4px;
}

.chip-primary {
  background: #eef3ff;
  border: 1px solid #c8d7f5;
  border-radius: 999px;
  display: inline-block;
  padding: 2px 8px;
  text-decoration: none;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
}

.tag-type-system {
  color: var(--emalm-tag-system-color, #000);
}

.tag-type-0 {
  color: var(--emalm-tag-general-color, #006ffa);
}

.tag-type-1 {
  color: var(--emalm-tag-artist-color, #ff0000);
}

.tag-type-3 {
  color: var(--emalm-tag-copyright-color, #b000b0);
}

.tag-type-4 {
  color: var(--emalm-tag-character-color, #00a000);
}

.tag-type-5 {
  color: var(--emalm-tag-meta-color, #ff4a00);
}

.diff-list ins {
  background: #e2f8dd;
  color: #217821;
  text-decoration: none;
}

.diff-list del {
  background: #ffe3e3;
  color: #9b2727;
  text-decoration: line-through;
}

.prose {
  line-height: 1.55;
}

.popup-menu {
  position: relative;
}

.popup-menu-button {
  align-items: center;
  border: 1px solid var(--emalm-listing-border);
  border-radius: 6px;
  display: inline-flex;
  justify-content: center;
  min-height: 28px;
  min-width: 32px;
  padding: 2px 8px;
  text-decoration: none;
}

.popup-menu-content {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.14);
  display: none;
  list-style: none;
  margin: 4px 0 0;
  min-width: 150px;
  padding: 6px 0;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 100;
}

.popup-menu.is-open .popup-menu-content,
.popup-menu:focus-within .popup-menu-content {
  display: block;
}

.popup-menu-content a {
  display: block;
  padding: 5px 12px;
  white-space: nowrap;
}

.popup-menu-content a:hover {
  background: #eef3ff;
  text-decoration: none;
}

.popup-menu-content hr {
  border: 0;
  border-top: 1px solid var(--emalm-listing-border);
  margin: 4px 0;
}

.control-column {
  white-space: nowrap;
}

@media (max-width: 760px) {
  #page.emalm-listing-page,
  .emalm-listing-page {
    margin: 10px;
  }

  .simple_form.search-form.inline-form.emalm-search-form,
  form.search-form.inline-form.emalm-search-form,
  .emalm-search-form {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .emalm-search-form label,
  .emalm-search-form input[type="text"],
  .emalm-search-form input[type="search"],
  .emalm-search-form input[type="date"],
  .emalm-search-form input[type="number"],
  .emalm-search-form input:not([type]),
  .emalm-search-form select,
  .emalm-search-form textarea,
  .emalm-search-form input[type="submit"],
  .emalm-search-form button[type="submit"],
  .emalm-search-submit {
    grid-column: 1;
    justify-self: stretch;
    text-align: left;
    width: 100%;
  }

  .emalm-table.is-responsive thead,
  table.striped.is-responsive thead {
    display: none;
  }

  .emalm-table.is-responsive tr,
  .emalm-table.is-responsive td,
  table.striped.is-responsive tr,
  table.striped.is-responsive td {
    display: block;
  }

  .emalm-table.is-responsive td::before,
  table.striped.is-responsive td::before {
    color: var(--emalm-listing-muted);
    content: attr(data-label);
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }
}
