/* ---------- The TMDB search window (js/searchModal.js) ----------

   Results on the left, the picked one's details on the right; on a phone
   one at a time. The window has a fixed height so each side scrolls on its
   own instead of the whole window growing with the results. */

.modal-tmdb {
  width: min(1040px, calc(100vw - 64px));
  height: min(720px, calc(100vh - 64px));
  max-height: none;
  overflow: hidden;
  border-radius: 0;
}

/* ---------- the search field ---------- */

.tmdb-search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.tmdb-search-field svg {
  position: absolute;
  left: 15px;
  width: 18px;
  height: 18px;
  color: var(--ink-muted);
  pointer-events: none;
}

.tmdb-search-field input {
  width: 100%;
  padding: 13px 46px 13px 44px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--accent-deep);
  border-radius: 0;
  outline: none;
  transition: box-shadow var(--transition);
}

.tmdb-search-field input::placeholder {
  color: var(--ink-muted);
}

.tmdb-search-field input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-strong) 30%, transparent);
}

/* The field's own clear button: the browser's is hidden so there's one. */
.tmdb-search-field input::-webkit-search-cancel-button {
  display: none;
}

.tmdb-clear {
  position: absolute;
  right: 9px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--paper-dim);
  color: var(--ink-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.tmdb-clear:hover {
  color: var(--ink);
}

.tmdb-status {
  min-height: 1.5em;
  margin: 8px 0 10px;
  font-size: 13px;
  color: var(--ink-muted);
}

.tmdb-status.is-error {
  color: #dc2626;
  font-weight: 600;
}

/* ---------- results | details ---------- */

.tmdb-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 20px;
}

.tmdb-hits {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 6px 8px 2px;
}

.tmdb-hit {
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 3px solid transparent;
  transition: background var(--transition);
}

.tmdb-hit:hover {
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}

.tmdb-hit.is-current {
  background: #fff;
  border-left-color: var(--accent-strong);
  box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.12);
}

.tmdb-hit-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.tmdb-hit-poster {
  display: block;
  width: 54px;
  aspect-ratio: 2 / 3;
  flex: none;
  object-fit: cover;
  background: var(--surface);
}

.tmdb-hit-text {
  display: grid;
  min-width: 0;
}

.tmdb-hit .tmdb-row-title {
  font-size: 20px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.tmdb-hit .tmdb-row-year {
  margin-top: 2px;
  font-size: 13px;
}

.tmdb-hit-have {
  flex: none;
  padding-right: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  white-space: nowrap;
}

.tmdb-hit.is-have .tmdb-hit-poster {
  filter: grayscale(0.7);
  opacity: 0.75;
}

/* Pick it without opening it: a round toggle on the row. */
.tmdb-pick {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  margin-right: 8px;
  border: 2px solid var(--accent-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--accent-deep);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.tmdb-pick[aria-pressed="true"] {
  background: var(--accent-strong);
  color: #fff;
}

.tmdb-pick:hover {
  background: color-mix(in srgb, var(--accent-strong) 15%, transparent);
}

.tmdb-pick[aria-pressed="true"]:hover {
  background: var(--accent-deep);
}

/* ---------- the details side ---------- */

.tmdb-preview {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 20px 18px;
  background: color-mix(in srgb, #fff 65%, var(--paper));
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.14);
}

/* Nothing picked yet: says what to do, on a dashed empty frame. */
.tmdb-preview-hint {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 180px;
  padding: 20px;
  border: 2px dashed color-mix(in srgb, var(--ink) 18%, transparent);
  text-align: center;
}

.tmdb-preview-hand {
  max-width: 26ch;
  font-family: var(--font-hand);
  font-size: 22px;
  line-height: 1.25;
  color: var(--ink-muted);
}

.tmdb-preview-back {
  display: none;
  margin-bottom: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-deep);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.tmdb-preview-top {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tmdb-preview-poster-wrap {
  position: relative;
  margin: 6px 0 0 6px;
  transform: rotate(-2deg);
}

.tmdb-preview-poster {
  display: block;
  width: 124px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--surface);
  box-shadow: 0 0 0 6px #fff, 0 0 0 7px color-mix(in srgb, var(--ink) 15%, transparent), 3px 6px 12px rgba(0, 0, 0, 0.25);
}

/* Already there: stamped on the poster, like the collection picker's. */
.tmdb-have-stamp {
  position: absolute;
  top: 12px;
  left: 6px;
  max-width: calc(100% - 12px);
  padding: 1px 6px;
  border: 2px solid #fff;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
  transform: rotate(-9deg);
  pointer-events: none;
}

.tmdb-preview-head .detail-title {
  font-size: 30px;
}

.tmdb-preview-head .detail-meta-runtime {
  margin-top: 6px;
}

.tmdb-preview-head .detail-genre-line {
  margin-top: 6px;
}

/* Picked, and its details on the way. */
.tmdb-preview-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  font-size: 14px;
  color: var(--ink-muted);
}

.tmdb-preview-dots {
  display: inline-flex;
  gap: 4px;
}

.tmdb-preview-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-strong);
  animation: tmdb-dot 0.9s ease-in-out infinite;
}

.tmdb-preview-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.tmdb-preview-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes tmdb-dot {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.tmdb-preview-failed {
  margin-top: 22px;
  font-size: 14px;
  font-weight: 600;
  color: #dc2626;
}

.tmdb-preview-retry {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-deep);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.tmdb-preview .detail-synopsis {
  margin-top: 22px;
}

.tmdb-preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  margin-top: 20px;
}

.tmdb-preview-actions .detail-trailer {
  margin-top: 0;
}

/* The trailer, when opened, takes the whole row under the buttons. */
.tmdb-preview-actions .detail-trailer:has(.detail-trailer-frame) {
  flex-basis: 100%;
}

.tmdb-preview-action.is-picked {
  background: var(--accent-deep);
}

/* ---------- the picked ones ---------- */

.batch-picked {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-height: 68px;
  overflow-y: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}

.batch-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 2px 2px 10px;
  background: color-mix(in srgb, var(--accent-strong) 18%, var(--paper));
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 15px;
  font-weight: 400;
}

.batch-chip button {
  padding: 2px 6px;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.batch-chip button:hover {
  color: var(--ink);
}

/* ---------- phones: one side at a time ---------- */

@media (max-width: 720px) {
  .modal-tmdb {
    width: calc(100vw - 20px);
    height: calc(100dvh - 24px);
  }

  .tmdb-split {
    grid-template-columns: minmax(0, 1fr);
  }

  .tmdb-split.is-previewing .tmdb-hits,
  .tmdb-split:not(.is-previewing) .tmdb-preview {
    display: none;
  }

  .tmdb-preview-back {
    display: inline-block;
  }

  .tmdb-preview {
    padding: 16px 14px;
  }

  .tmdb-preview-top {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 16px;
  }

  .tmdb-preview-poster {
    width: 96px;
  }

  .tmdb-have-stamp {
    font-size: 9.5px;
  }

  .tmdb-preview-head .detail-title {
    font-size: 24px;
  }

  .batch-footer {
    flex-direction: column;
    align-items: stretch;
  }
}
