/*
 * Catalog and content editor additions.
 * Loaded after styles.css, navigation.css, and enhancements.css.
 * The rules intentionally reuse the existing warm cream / pastel palette.
 */

/* Native hidden state must remain authoritative. */
[hidden],
#alphabet-filter[hidden],
#content-modal-backdrop[hidden],
#work-preview-backdrop[hidden],
#credit-error[hidden],
#content-error[hidden] {
  display: none !important;
}

/* Shared resilience for translated names and long editorial copy. */
body {
  overflow-x: hidden;
}

#alphabet-filter,
.alphabet-filter,
.catalog-heading,
.catalog-heading > *,
.content-card,
.work-card-body,
.content-form-layout,
.content-form-layout > *,
.credit-row,
.credit-person,
.credit-actions,
.work-preview-layout,
.work-preview-copy,
.work-credit-group {
  min-width: 0;
}

button,
a,
input,
textarea,
select,
dt,
dd,
p,
strong,
small {
  overflow-wrap: anywhere;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(232, 137, 117, .34);
  outline-offset: 3px;
}

/* Shared A–Z filter. */
#alphabet-filter.alphabet-filter {
  margin: 0 0 18px;
  padding: 13px 15px 12px;
  border: 1px solid var(--nav-line, var(--line, #eee3db));
  border-radius: 14px;
  background: #fffdfb;
}

.alphabet-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.alphabet-heading label {
  color: var(--ink, #39302d);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .04em;
}

#alphabet-summary {
  margin: 0;
  color: var(--muted, #887a73);
  font-size: 10px;
  line-height: 1.35;
  text-align: right;
}

.alphabet-strip {
  display: flex;
  align-items: stretch;
  gap: 5px;
  max-width: 100%;
  padding: 1px 1px 4px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  touch-action: pan-x;
}

.alphabet-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line, #eee3db);
  border-radius: 10px;
  background: var(--white, #fff);
  color: var(--muted, #887a73);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.1;
  white-space: nowrap;
}

.alphabet-button:hover,
.alphabet-button:focus-visible,
.alphabet-button.is-active {
  border-color: #e6b0a2;
  background: #fff1e9;
  color: var(--coral-deep, #cd6958);
}

.alphabet-button.is-active {
  box-shadow: inset 0 -2px 0 var(--coral, #e88975);
}

.alphabet-button[data-initial="all"] {
  color: var(--ink, #39302d);
}

.alphabet-button[data-initial="other"],
.alphabet-button[data-initial="missing"] {
  min-width: 62px;
}

.alphabet-button[data-initial="missing"] {
  white-space: nowrap;
}

/* Language-name helper used in cards, profiles, and previews. */
dl.language-names {
  display: grid;
  gap: 3px;
  max-width: 100%;
  margin: 0;
  color: var(--muted, #887a73);
  font-size: 11px;
  line-height: 1.3;
}

.language-name {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
}

.language-name dt {
  color: #aa9990;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.language-name dd {
  min-width: 0;
  margin: 0;
  color: var(--muted, #887a73);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.person-card h3 {
  overflow: visible;
  white-space: normal;
}

.person-card h3 .card-language-names {
  display: block;
  margin-top: 6px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
}

.profile-copy .language-names {
  margin: 10px 0 0;
}

.preview-meta .language-names,
.work-card .language-names,
.work-preview-copy .language-names {
  margin-top: 8px;
}

/* Artist reverse panel. */
.artist-works {
  margin-top: 22px;
  padding: 19px;
  border: 1px solid #f0e1d8;
  border-radius: var(--radius-md, 18px);
  background: #fff8f3;
}

.artist-works > h3,
.artist-work-group > h4 {
  margin: 0;
  color: var(--ink, #39302d);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}

.artist-works > h3 {
  margin-bottom: 14px;
  font-size: 23px;
}

.artist-work-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.artist-work-group {
  min-width: 0;
  padding: 13px;
  border: 1px solid #f0e1d8;
  border-radius: 13px;
  background: var(--white, #fff);
}

.artist-work-group > h4 {
  margin-bottom: 9px;
  color: var(--coral-deep, #cd6958);
  font-size: 17px;
}

.artist-work-list {
  display: grid;
  gap: 6px;
}

.artist-work-link {
  display: grid;
  width: 100%;
  gap: 3px;
  min-height: 48px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: #fffaf7;
  color: var(--ink, #39302d);
  text-align: left;
  text-decoration: none;
}

.artist-work-link:hover,
.artist-work-link:focus-visible {
  border-color: #f0d1c5;
  background: #fff1e9;
}

.artist-work-link strong,
.artist-work-link small {
  display: block;
  min-width: 0;
}

.artist-work-link strong {
  font-size: 12px;
  line-height: 1.35;
}

.artist-work-link small {
  color: var(--muted, #887a73);
  font-size: 10px;
  line-height: 1.35;
}

.artist-work-empty {
  margin: 0;
  color: var(--muted, #887a73);
  font-size: 11px;
  line-height: 1.5;
}

/* Catalog heading and poster-led work cards. */
.catalog-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 17px;
}

.catalog-heading-title {
  min-width: 0;
}

#catalog-title {
  margin: 0;
}

#catalog-result-count {
  margin: 6px 0 0;
  color: var(--muted, #887a73);
  font-size: 11px;
  line-height: 1.4;
}

#add-content {
  flex: 0 0 auto;
  white-space: nowrap;
}

.catalog-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.content-card.work-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  padding: 0;
}

.work-poster {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--paper-deep, #f8efe7);
}

.work-poster img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.work-card-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  padding: 17px 18px 16px;
}

.work-card-body .content-kind {
  align-self: flex-start;
  margin-bottom: 10px;
}

.work-title-button {
  display: block;
  width: 100%;
  margin: 0 0 7px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink, #39302d);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: 1.1;
  text-align: left;
}

.work-title-button:hover {
  color: var(--coral-deep, #cd6958);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.work-card-body .content-meta {
  margin-bottom: 10px;
}

.work-card-body .content-summary {
  flex: 1 1 auto;
}

.work-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 15px;
}

.work-card-actions .small-action {
  width: auto;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line, #eee3db);
  background: var(--white, #fff);
  color: var(--muted, #887a73);
  font-size: 10px;
  font-weight: 700;
}

.work-card-actions .small-action:hover {
  border-color: #e6b0a2;
  background: #fff2eb;
  color: var(--coral-deep, #cd6958);
}

.source-link {
  color: var(--coral-deep, #cd6958);
  font-size: 11px;
  font-weight: 700;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.source-link:hover {
  color: var(--ink, #39302d);
}

/* Content editor modal. The existing .modal supplies shared border/shadow/animation. */
section#content-modal.modal.content-modal {
  width: min(100%, 800px);
  max-height: min(90dvh, 900px);
  overflow: auto;
  padding: 24px;
  overscroll-behavior: contain;
}

.content-modal .modal-intro {
  max-width: 660px;
}

.content-form-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: start;
  gap: 22px;
}

.content-form-layout > .poster-picker,
.content-form-layout > .poster-column {
  min-width: 0;
}

.poster-picker {
  min-width: 0;
}

#poster-edit-preview.poster-edit-preview {
  display: grid;
  width: 100%;
  max-width: 180px;
  max-height: 260px;
  aspect-ratio: 2 / 3;
  place-items: center;
  overflow: hidden;
  border: 1px solid #efd8cc;
  border-radius: 12px;
  background: var(--paper-deep, #f8efe7);
  color: var(--muted, #887a73);
  font-size: 11px;
  text-align: center;
}

#poster-edit-preview img,
.poster-edit-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.poster-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  flex-wrap: wrap;
}

#poster-file {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  color: var(--muted, #887a73);
  font-size: 12px;
}

#remove-poster {
  white-space: nowrap;
}

.content-form-fields {
  min-width: 0;
}

.multilingual-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

label.inputbox {
  display: block;
  min-width: 0;
}

label.inputbox dt {
  margin: 0 0 7px;
  color: #66544c;
  font-size: 11px;
  font-weight: 700;
}

label.inputbox dd {
  min-width: 0;
  margin: 0;
}

label.inputbox .text-input,
label.inputbox textarea {
  max-width: 100%;
}

.content-credits {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line, #eee3db);
}

.credit-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.credit-section-heading h3 {
  margin: 0;
  color: var(--ink, #39302d);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 400;
}

.credit-section-heading button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 10px;
}

.credit-list {
  display: grid;
  gap: 7px;
}

.credit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #f0e1d8;
  border-radius: 10px;
  background: #fffaf7;
}

.credit-person {
  flex: 1 1 170px;
  min-width: 0;
}

.credit-person-name,
.credit-role,
.credit-note {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.credit-person-name {
  color: var(--ink, #39302d);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.credit-role,
.credit-note {
  margin-top: 2px;
  color: var(--muted, #887a73);
  font-size: 10px;
  line-height: 1.35;
}

.credit-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  flex-wrap: wrap;
}

.credit-actions button {
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line, #eee3db);
  border-radius: 8px;
  background: var(--white, #fff);
  color: var(--muted, #887a73);
  font-size: 10px;
  font-weight: 700;
}

.credit-actions button:hover {
  border-color: #e6b0a2;
  background: #fff2eb;
  color: var(--coral-deep, #cd6958);
}

/* Inline credit picker: deliberately not a second modal. */
#credit-picker.credit-picker {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid #e8d5ca;
  border-radius: 13px;
  background: var(--paper, #fffaf5);
}

.credit-picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.credit-picker-heading h4 {
  margin: 0;
  color: var(--ink, #39302d);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 400;
}

#credit-search.text-input {
  margin-bottom: 10px;
}

.credit-picker-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: 270px;
  overflow: auto;
  overscroll-behavior: contain;
}

.credit-choice button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 7px 8px;
  border: 1px solid var(--line, #eee3db);
  border-radius: 9px;
  background: var(--white, #fff);
  color: var(--ink, #39302d);
  text-align: left;
}

.credit-choice button:hover,
.credit-choice button:focus-visible,
.credit-choice.is-selected button {
  border-color: #e6b0a2;
  background: #fff1e9;
}

.credit-choice-name,
.credit-choice-meta {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.credit-choice-name {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.credit-choice-meta {
  margin-top: 2px;
  color: var(--muted, #887a73);
  font-size: 9px;
  line-height: 1.3;
}

.credit-choice-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--peach, #f8ded1);
  color: var(--coral-deep, #cd6958);
  font-size: 10px;
  font-weight: 750;
}

.credit-choice-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.credit-selected {
  min-height: 18px;
  margin: 10px 0 8px;
  padding: 8px 9px;
  border-left: 3px solid var(--peach, #f8ded1);
  background: #fff6f0;
  color: var(--muted, #887a73);
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.credit-picker .text-input {
  margin-bottom: 9px;
}

.credit-picker-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 10px;
}

.credit-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.form-error {
  margin: 8px 0 0;
  padding: 9px 11px;
  border: 1px solid #efc7ba;
  border-radius: 9px;
  background: #fff0eb;
  color: #a45040;
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* Work preview modal. No z-index is introduced here so existing quick artist
   previews retain their established stacking order when opened from a card. */
#work-preview-modal.modal.work-preview-modal {
  width: min(100%, 780px);
  max-height: 85dvh;
  overflow: auto;
  overscroll-behavior: contain;
}

.work-preview-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}

.work-preview-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 12px;
  background: var(--paper-deep, #f8efe7);
}

.work-preview-poster img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.work-preview-copy {
  min-width: 0;
}

.work-preview-copy h2 {
  overflow-wrap: anywhere;
}

.work-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 17px 0 0;
}

.work-facts div {
  min-width: 0;
}

.work-facts dt {
  margin-bottom: 3px;
  color: var(--muted, #887a73);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.work-facts dd {
  min-width: 0;
  margin: 0;
  color: var(--ink, #39302d);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.work-credits {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.work-credit-group {
  min-width: 0;
  padding: 12px;
  border: 1px solid #f0e1d8;
  border-radius: 12px;
  background: #fffaf7;
}

.work-credit-group h3 {
  margin: 0 0 8px;
  color: var(--ink, #39302d);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 400;
}

.work-credit-group .credit-list {
  gap: 5px;
}

.work-credit-group .credit-row {
  display: block;
  padding: 7px 8px;
  border: 0;
  background: var(--white, #fff);
}

.work-credit-group .credit-row .person-name-button {
  display: inline;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
}

.work-credit-group .credit-row .person-name-button:hover {
  color: var(--coral-deep, #cd6958);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.work-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 21px;
  flex-wrap: wrap;
}

.work-preview-actions .primary-button {
  min-width: 110px;
}

@media (max-width: 950px) {
  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .alphabet-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  #alphabet-summary {
    text-align: left;
  }

  .catalog-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 11px;
  }

  #add-content {
    width: 100%;
  }

  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .artist-work-groups,
  .multilingual-fields,
  .credit-picker-fields,
  .credit-picker-results,
  .work-credits,
  .work-facts {
    grid-template-columns: 1fr;
  }

  section#content-modal.modal.content-modal {
    padding: 18px;
  }

  .content-form-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  #poster-edit-preview.poster-edit-preview {
    width: min(100%, 180px);
  }

  .poster-controls {
    align-items: stretch;
    flex-direction: column;
  }

  #poster-file {
    font-size: 16px;
  }

  .poster-controls #remove-poster {
    align-self: flex-start;
  }

  .credit-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .credit-person {
    flex-basis: calc(100% - 10px);
  }

  .credit-actions {
    flex-basis: 100%;
  }

  #credit-search.text-input,
  .content-modal input,
  .content-modal textarea,
  .content-modal select,
  .work-preview-modal input,
  .work-preview-modal textarea,
  .work-preview-modal select {
    font-size: 16px;
  }

  #work-preview-modal.modal.work-preview-modal {
    max-height: 85dvh;
  }

  .work-preview-layout {
    grid-template-columns: 1fr;
    gap: 17px;
  }

  .work-preview-poster {
    width: min(100%, 180px);
  }

  .work-preview-actions > * {
    flex: 1 1 auto;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .alphabet-strip,
  .credit-picker-results,
  section#content-modal.modal.content-modal,
  #work-preview-modal.modal.work-preview-modal {
    scroll-behavior: auto;
  }
}

/* Match the concrete generated editor markup. */
.dropdown-add-button {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 5px;
  padding: 10px 13px;
  border: 0;
  border-top: 1px solid var(--line, #eee3db);
  background: #fff4eb;
  color: var(--coral-deep, #cd6958);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}
.alphabet-heading > span:first-child { color: var(--ink, #39302d); font-size: 11px; font-weight: 650; }
.person-card > .card-language-names { margin: 8px 0 10px; }
.credit-picker-result {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 50px;
  padding: 9px;
  border: 1px solid var(--line, #eee3db);
  border-radius: 9px;
  background: #fff;
  color: var(--ink, #39302d);
  text-align: left;
}
.credit-picker-result:hover { background: #fff1e9; border-color: #e6b0a2; }
.credit-picker-heading h3 { margin: 0; font-size: 19px; }
.artist-work-list, .work-credit-group ul { list-style: none; padding: 0; margin: 0; }
.work-credit-group { margin-top: 12px; }
.work-credit-group .credit-row strong, .work-credit-group .credit-row small { display: block; margin-top: 4px; font-size: 11px; }
.work-card-body .content-kind { border: 0; }
.work-counts { color: var(--muted, #887a73); font-size: 11px; }
.work-poster-empty { display: grid; width: 100%; height: 100%; place-items: center; font-size: 11px; color: var(--muted, #887a73); }
.work-preview-summary { white-space: pre-wrap; font-size: 13px; line-height: 1.6; }
