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

:root {
  --emalm-listing-border: var(--emalm-ui-border);
  --emalm-listing-border-soft: color-mix(in srgb, var(--emalm-ui-border) 72%, var(--emalm-ui-surface-1) 28%);
  --emalm-listing-panel: var(--emalm-ui-surface-1);
  --emalm-listing-panel-muted: var(--emalm-ui-surface-2);
  --emalm-listing-row-alt: color-mix(in srgb, var(--emalm-ui-surface-1) 80%, var(--emalm-ui-surface-2) 20%);
  --emalm-listing-row-hover: color-mix(in srgb, var(--emalm-ui-surface-1) 68%, var(--emalm-ui-accent-soft) 32%);
  --emalm-listing-muted: var(--emalm-ui-text-muted);
  --emalm-listing-focus: var(--emalm-ui-accent-soft);
}

#page.emalm-listing-page,
.emalm-listing-page {
  background: transparent !important;
  border: 0;
  box-shadow: none;
  margin: 18px 24px 32px;
  max-width: none;
  width: auto;
  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;
}

.artist-commentary-value {
  white-space: pre-wrap;
}

.artist-commentary-value.prose {
  white-space: normal;
}

.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: var(--emalm-ui-text-muted);
  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-resource-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-resource-autocomplete {
  left: 0;
  min-width: 100%;
  right: 0;
  width: auto;
}

.media-assets-listing-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.media-assets-tab-list,
.media-assets-columns-list {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}

.media-assets-tab-list li,
.media-assets-columns-list li {
  margin: 0;
}

.media-assets-posted-tabs {
  gap: 0;
}

.media-assets-posted-tabs a {
  background: var(--emalm-listing-panel);
  border: 1px solid var(--emalm-listing-border);
  color: inherit;
  display: block;
  padding: 5px 10px;
  text-decoration: none;
}

.media-assets-posted-tabs li + li a {
  border-left-width: 0;
}

.media-assets-posted-tabs li:first-child a {
  border-radius: 5px 0 0 5px;
}

.media-assets-posted-tabs li:last-child a {
  border-radius: 0 5px 5px 0;
}

.media-assets-posted-tabs a:hover,
.media-assets-posted-tabs a:focus-visible {
  background: var(--emalm-listing-focus);
  text-decoration: none;
}

.media-assets-posted-tabs a.active {
  background: var(--emalm-ui-accent);
  border-color: var(--emalm-ui-accent);
  color: var(--emalm-ui-on-accent, #fff);
}

.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: var(--emalm-listing-panel);
  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: var(--emalm-ui-text-muted);
}

.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: var(--emalm-listing-panel);
  border-collapse: collapse;
  width: 100%;
}

#page table:not(.emalm-table-no-style),
main.emalm-static-page table:not(.emalm-table-no-style) {
  background: var(--emalm-listing-panel);
  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);
}

.notes-listing-table .post-preview {
  margin: 0 auto;
  max-width: 200px;
}

.post-notes-table td[data-label="Post"] {
  min-width: 220px;
  width: 220px;
}

.post-notes-table .post-preview {
  max-width: 180px;
  width: 180px;
}

.post-notes-table .post-preview-container,
.post-notes-table .post-preview-link {
  min-width: 180px;
  width: 180px;
}

.notes-listing-table .notes-post-preview-link {
  font-size: 12px;
  margin-top: 6px;
  text-align: center;
}

.notes-listing-table .note-version-body-snippet {
  max-width: 48rem;
  overflow-wrap: anywhere;
}

.notes-listing-table .note-version-badge {
  background: var(--emalm-listing-panel-muted);
  border: 1px solid var(--emalm-listing-border-soft);
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 6px 6px 0;
  padding: 2px 8px;
}

.notes-listing-table .note-version-badge.current {
  background: color-mix(in srgb, var(--emalm-ui-success-bg) 78%, var(--emalm-listing-panel) 22%);
  border-color: var(--emalm-ui-success-border);
  color: var(--emalm-ui-success-text);
}

.notes-listing-table .note-version-badge.deleted {
  background: color-mix(in srgb, var(--emalm-ui-danger-bg) 78%, var(--emalm-listing-panel) 22%);
  border-color: var(--emalm-ui-danger-border);
  color: var(--emalm-ui-danger-text);
}

.notes-listing-table .note-version-badge.neutral {
  color: var(--emalm-listing-muted);
}

.note-versions-bulk-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}

table.autofit {
  table-layout: auto;
}

.col-expand {
  width: 100%;
}

.emalm-listing-empty,
.emalm-activity-empty,
.emalm-activity-admin-only {
  background: var(--emalm-ui-warning-bg);
  border: 1px solid var(--emalm-ui-warning-border);
  border-radius: 8px;
  color: var(--emalm-ui-warning-text);
  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: var(--emalm-ui-text-muted);
  font-size: 12px;
  margin-left: 4px;
}

.chip-primary {
  background: color-mix(in srgb, var(--emalm-ui-surface-1) 70%, var(--emalm-ui-accent-soft) 30%);
  border: 1px solid color-mix(in srgb, var(--emalm-ui-accent) 38%, var(--emalm-ui-border) 62%);
  border-radius: 999px;
  display: inline-block;
  padding: 2px 8px;
  text-decoration: none;
}

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

.search-tag-list {
  display: grid;
  gap: 4px;
}

.search-tag-list > li {
  min-width: 0;
}

.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);
}

a.user-banned-color {
  color: var(--user-banned-color, #777);
}

a.user-banned-color:hover {
  color: var(--user-banned-hover-color, #666);
}

.diff-list ins {
  background: var(--emalm-ui-success-bg);
  color: var(--emalm-ui-success-text);
  text-decoration: none;
}

.diff-list del {
  background: var(--emalm-ui-danger-bg);
  color: var(--emalm-ui-danger-text);
  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: var(--emalm-listing-panel);
  border: 1px solid var(--emalm-listing-border);
  border-radius: 8px;
  box-shadow: var(--emalm-ui-shadow-soft);
  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 {
  display: block;
}

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

.popup-menu-content a:hover {
  background: color-mix(in srgb, var(--emalm-ui-surface-1) 68%, var(--emalm-ui-accent-soft) 32%);
  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;
}

.activity-events-actions,
.activity-preferences-form,
.activity-subscription-form,
.activity-subscriptions-filter,
.activity-subscription-manage-form,
.activity-inline-form,
.media-search-activity-subscription {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 12px;
}

.media-search-activity-subscription {
  flex-wrap: nowrap;
}

.media-search-activity-subscription .activity-subscription-category-grid {
  align-items: center;
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0;
  padding: 0;
}

.media-search-activity-subscription .activity-subscription-category-grid legend {
  float: left;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.8;
  margin: 0 4px 0 0;
  padding: 0;
  width: auto;
}

.activity-event-type-grid {
  display: grid;
  gap: 4px 12px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin: 8px 0;
  max-width: 760px;
}

.activity-subscriptions-table tr.is-muted {
  opacity: 0.68;
}

.activity-event--important td {
  background: var(--emalm-ui-info-bg);
}

.activity-event--warning td {
  background: var(--emalm-ui-warning-bg);
}

.activity-event--critical td {
  background: var(--emalm-ui-danger-bg);
  border-top-color: var(--emalm-ui-danger-border);
}

@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;
  }
}

.sessions-page .card {
  align-items: stretch;
  max-width: 440px;
  width: min(440px, 100%);
}

.emalm-login-form,
.emalm-register-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.emalm-login-form .input:not(.session_remember),
.emalm-register-form .input:not(.session_remember) {
  align-items: center;
  display: grid;
  gap: 8px 12px;
  grid-template-columns: minmax(140px, max-content) minmax(180px, 260px);
}

.emalm-login-form label,
.emalm-register-form label {
  font-weight: 700;
  margin: 0;
}

.emalm-login-form input[type="text"],
.emalm-login-form input[type="password"],
.emalm-register-form input[type="text"],
.emalm-register-form input[type="email"],
.emalm-register-form input[type="password"] {
  box-sizing: border-box;
  width: 100%;
}

.emalm-login-form .hint,
.emalm-login-form .fineprint,
.emalm-register-form .hint,
.emalm-register-form .fineprint {
  grid-column: 2;
  margin: -4px 0 0;
}

.emalm-login-form > input[type="submit"],
.emalm-login-form > .notice,
.emalm-login-form > .mb-4,
.emalm-register-form > input[type="submit"],
.emalm-register-form > .notice,
.emalm-register-form > .mb-4 {
  margin-left: calc(140px + 12px);
  width: min(260px, 100%);
}

.emalm-login-form .session_remember,
.emalm-login-form .session_remember label,
.emalm-register-form .session_remember,
.emalm-register-form .session_remember label {
  display: block;
}

@media (max-width: 520px) {
  .emalm-login-form .input:not(.session_remember),
  .emalm-register-form .input:not(.session_remember) {
    align-items: stretch;
    grid-template-columns: 1fr;
  }
  .emalm-login-form .hint,
  .emalm-login-form .fineprint,
  .emalm-register-form .hint,
  .emalm-register-form .fineprint {
    grid-column: 1;
    margin-top: 0;
  }
  .emalm-login-form > input[type="submit"],
  .emalm-login-form > .notice,
  .emalm-login-form > .mb-4,
  .emalm-register-form > input[type="submit"],
  .emalm-register-form > .notice,
  .emalm-register-form > .mb-4 {
    margin-left: 0;
    width: 100%;
  }
}
