/* Map cards shuffle across a darkened world, then one card becomes the result. */
.random-open {
  overflow: hidden;
}
.random-draw {
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: clamp(14px, 3vw, 32px);
  border: 0;
  background: var(--texture), color-mix(in srgb, var(--bg) 96%, transparent);
  color: var(--ink);
  overflow: hidden;
}
.random-draw::backdrop {
  background: var(--modal-veil);
}
.random-shell {
  width: min(1184px, 100%);
  height: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.random-header,
.random-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex: 0 0 auto;
}
.random-heading {
  display: flex;
  align-items: center;
  gap: 16px;
}
.random-heading > .icon {
  width: 52px;
  height: 52px;
}
.random-eyebrow {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 2px;
}
.random-header h2 {
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.45;
}
#random-pool {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.random-close,
.random-skip {
  color: var(--ink);
  background: var(--raised);
  border: 2px solid var(--edge);
  box-shadow: var(--archive-control-shadow);
}
.random-close {
  align-self: flex-start;
  flex-shrink: 0;
}
.random-close:hover,
.random-skip:hover {
  background: var(--soft);
  color: var(--accent);
}
.random-draw :focus-visible {
  outline-color: var(--accent);
}
.random-stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  align-items: safe center;
  overflow: hidden;
  isolation: isolate;
}
.random-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 400ms;
}
.random-draw[data-phase="loading"] .random-field {
  visibility: hidden;
}
.random-loading {
  margin: auto;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  color: var(--ink);
  text-align: center;
}
.random-loading > .icon {
  width: 56px;
  height: 56px;
}
.random-loading > strong {
  font-size: 18px;
}
.random-loading > span {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.random-tile {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  border: 3px solid var(--rim);
  border-right-color: var(--edge);
  border-bottom-color: var(--edge);
  box-shadow: 4px 4px #0006;
  transform-origin: 0 0;
  transition:
    opacity 260ms,
    box-shadow 260ms;
}
.random-field .random-tile {
  will-change: transform;
}
.random-cover {
  position: relative;
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  aspect-ratio: 16 / 9;
  background: var(--texture), var(--slot);
  overflow: hidden;
}
.random-cover-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}
.random-cover[data-state="ready"] > .random-cover-image {
  opacity: 1;
}
.random-cover[data-state="ready"] > .random-cover-placeholder {
  visibility: hidden;
}
.random-cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.random-cover-placeholder > .icon {
  width: 32px;
  height: 32px;
}
.random-tile.is-picked .random-cover-placeholder {
  font-size: 14px;
}
.random-tile.is-picked .random-cover-placeholder > .icon {
  width: 48px;
  height: 48px;
}
.random-tile h3 {
  padding: 10px;
  height: 42px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-top: 2px solid var(--line);
}
.random-draw[data-phase="selected"] .random-tile:not(.is-selected) {
  opacity: 0.25;
}
.random-tile.is-selected,
.random-tile.is-picked {
  border-color: var(--accent);
  box-shadow: 0 4px var(--shade);
  z-index: 2;
}
.random-draw:is(
    [data-phase="revealing"],
    [data-phase="settling"],
    [data-phase="ready"]
  )
  .random-field {
  opacity: 0.09;
}
.random-result {
  width: min(460px, calc(100% - 28px));
  margin: 18px auto;
  position: relative;
  z-index: 3;
  color: var(--ink);
}
.random-tile.is-picked {
  position: relative;
  width: 100%;
  height: auto;
  overflow: visible;
}
.random-tile.is-picked > .random-cover {
  flex: none;
  height: auto;
}
.random-tile.is-picked h3 {
  height: auto;
  min-height: 60px;
  padding: 14px 18px;
  font-size: clamp(18px, 2.2vw, 24px);
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
}
.random-info {
  opacity: 0;
  margin-top: 14px;
  padding: 18px;
  border: 2px solid var(--rim);
  border-right-color: var(--edge);
  border-bottom-color: var(--edge);
  background: var(--texture), var(--surface);
  box-shadow: 4px 4px #0005;
}
.random-draw:is([data-phase="settling"], [data-phase="ready"]) .random-info {
  opacity: 1;
}
.random-draw[data-phase="ready"] .random-stage {
  overflow-y: auto;
}
.random-draw[data-phase="ready"] .random-field h3 {
  visibility: hidden;
}
.random-draw[data-phase="ready"] .random-field .random-tile {
  will-change: auto;
}
.random-authors,
.random-genres,
.random-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.random-author {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  min-width: 0;
}
.random-author > span:last-child {
  overflow-wrap: anywhere;
}
.random-author .avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
}
.random-facts {
  justify-content: space-between;
  margin-top: 14px;
}
.random-genres {
  gap: 6px;
}
.random-genres .card-category {
  padding: 3px 6px;
  min-height: 30px;
  font-size: 12px;
}
.random-genres .icon {
  width: 20px;
  height: 20px;
}
.random-recordings {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.random-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.random-actions .button {
  flex: 1 1 auto;
  justify-content: center;
  min-height: 46px;
}
.random-actions .primary {
  flex-grow: 2;
}
.random-footer {
  min-height: 54px;
  justify-content: flex-end;
}
.random-skip {
  flex-shrink: 0;
  min-height: 44px;
}
.random-close-hint {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.random-close-hint kbd {
  background: var(--slot);
  color: var(--ink);
  border-color: var(--line);
}
@media (max-width: 600px) {
  .random-shell {
    gap: 12px;
  }
  .random-heading {
    gap: 10px;
  }
  .random-heading > .icon {
    width: 36px;
    height: 36px;
  }
  .random-header h2 {
    font-size: 21px;
  }
  .random-eyebrow {
    font-size: 11px;
  }
  .random-header {
    gap: 8px;
  }
  .random-field .random-tile h3 {
    height: 34px;
    padding: 6px;
    font-size: 11px;
  }
  .random-result {
    width: calc(100% - 14px);
    margin-block: 8px 14px;
  }
  .random-tile.is-picked h3 {
    padding: 10px 12px;
    min-height: 48px;
  }
  .random-info {
    padding: 12px;
  }
  .random-author {
    font-size: 13px;
    gap: 5px;
  }
  .random-actions {
    gap: 8px;
    margin-top: 14px;
  }
  .random-actions .button {
    padding-inline: 10px;
    font-size: 14px;
  }
  .random-footer {
    gap: 8px;
  }
  .random-skip {
    padding-inline: 10px;
    font-size: 13px;
  }
}
@media (hover: none), (pointer: coarse), (max-width: 600px) {
  .random-close-hint {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .random-draw *,
  .random-draw *::before,
  .random-draw *::after {
    transition: none !important;
  }
}
:root[data-motion="reduced"] .random-draw * {
  transition: none !important;
}
