/* play_modal (player.js): one element with two states -- 'paused' shows
   the full text (.info-scroll), 'playing' the synchronised captions
   (.player-captions) -- plus its options menu and controls. */

.player-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-modal-backdrop {
  touch-action: none;
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(2px);
}

.player-modal-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 672px;
  max-height: calc(100dvh - 1rem);
  margin: 0.5rem;
  background: var(--card-bg);
  border: 1px solid rgba(var(--fg-rgb), 0.12);
  border-radius: var(--radius);
  padding: 0.75rem 1.2rem 1.2rem;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
}

/* Night's card and page are both pure black -- the edge is the modal's
   only visible boundary, so make it a little stronger. */
:root[data-theme="night"] .player-modal-content {
  border: 1px solid rgba(var(--fg-rgb), 0.18);
}

.player-modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem;
}

.player-modal-close:hover {
  color: var(--text);
}

/* Options menu */
.player-modal-menu-toggle {
  position: absolute;
  top: 0.75rem;
  left: 0.8rem;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-modal-menu-toggle svg {
  width: 20px;
  height: 20px;
}

.player-modal-menu-toggle:hover,
.player-modal-menu-toggle[aria-expanded="true"] {
  color: var(--text);
}

.player-modal-menu {
  position: absolute;
  top: 2.6rem;
  left: 0.6rem;
  z-index: 1;
  min-width: 12rem;
  padding: 0.35rem 0;
  background: var(--card-bg);
  border: 1px solid rgba(var(--fg-rgb), 0.18);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
}

.player-modal-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.player-modal-menu-item:hover {
  background: rgba(var(--fg-rgb), 0.08);
}

.player-modal-menu-item:disabled {
  opacity: 0.5;
  cursor: default;
}

.menu-item-icon {
  flex: none;
  display: flex;
  color: var(--text-muted);
}

.menu-item-icon svg {
  width: 20px;
  height: 20px;
}

.player-modal-heart.active .menu-item-icon {
  color: var(--danger);
}

.player-modal-delete,
.player-modal-delete .menu-item-icon {
  color: var(--danger);
}

/* Title and passage list */
.player-modal-title {
  flex: none;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  /* First line centred on the menu toggle (top 0.75rem, 28px tall) and inset
     clear of it and the close button on either side. */
  line-height: 1.5rem;
  margin: 0.125rem 0 0;
  padding: 0 1.6rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.player-modal-subtitle {
  flex: none;
  overscroll-behavior: contain;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0.6rem 0 0 0;
  /* 3 lines visible; longer passage lists scroll (scrollbar hidden). */
  max-height: calc(3 * 1.45em);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.player-modal-subtitle::-webkit-scrollbar {
  display: none;
}

/* One clickable span per passage (renderSubtitle in player.js) -- nowrap so
   a reference never splits across lines. */
.subtitle-passage {
  cursor: pointer;
  white-space: nowrap;
}

.subtitle-passage.current {
  color: var(--text);
}

/* The two states (setState in player.js). */
.player-modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Outside .info-scroll so it stays put under the subtitle while the text
   scrolls; same colour as .info-passage-rule but subtitle-wide. */
.player-modal-body::before {
  content: '';
  flex: none;
  width: 95%;
  height: 1px;
  margin: 0.8rem auto 0;
  background: rgba(var(--fg-rgb), 0.18);
}

.player-modal.state-playing .info-scroll,
.player-modal.state-paused .player-captions {
  display: none;
}

/* Paused: description and full text */
.info-scroll {
  overscroll-behavior: contain;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-top: 0.6rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.info-scroll::-webkit-scrollbar {
  display: none;
}

.info-description {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 1rem;
  text-align: center;
}

/* The one place text is selectable (see body in base.css). */
.info-fulltext {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
  color: var(--text-muted);
  font-size: calc(0.9rem * var(--verse-scale));
  margin: 0;
  text-align: center;
}

/* One block per verse (see renderFullText in player.js): tight line-height
   inside a wrapped verse, clear gap between verses, bigger gap between
   passages -- so verse boundaries read at a glance. */
.info-verse {
  display: block;
  cursor: pointer;
  line-height: 1.35;
  margin-bottom: 0.75em;
}

.info-verse.current {
  color: var(--text);
}

.info-verse:last-child {
  margin-bottom: 0;
}

.info-verse.passage-start {
  margin-top: 1.25em;
}

/* Between passages (renderFullText in player.js) -- a sibling of the
   verses rather than a ::before on .passage-start, so scrolling a passage
   to the top (subtitle click) lands on its text with the rule just out of
   view. */
.info-passage-rule {
  display: block;
  width: 30%;
  height: 1px;
  margin: 0.5em auto 0;
  background: rgba(var(--fg-rgb), 0.18);
}

/* Playing: captions */
.player-captions {
  overscroll-behavior: contain;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow-y: auto;
  font-size: calc(1rem * var(--verse-scale));
  line-height: 1.4;
  padding: 0.4rem;
}

.player-captions-text {
  color: var(--text);
  white-space: pre-line;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.player-captions-ref {
  display: block;
  /* one blank caption line (1.4 line-height / 0.8 font-size) */
  margin-top: 1.75em;
  font-size: 0.8em;
}

.player-captions-text.faded {
  color: var(--text-muted);
  opacity: 0.7;
}

/* Controls */
.player-modal-controls {
  flex: none;
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.9rem;
}

.player-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.player-modal-controls .player-time-current {
  text-align: right;
}

.player-modal-controls .player-time-duration {
  text-align: left;
}

/* Fixed width so the Play and Pause labels give an identically sized button. */
.player-modal-toggle {
  width: 8.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 0;
  border-radius: 999px;
  cursor: pointer;
}

.player-modal-toggle-icon {
  display: flex;
}

.player-modal-toggle-icon svg {
  width: 18px;
  height: 18px;
}

.player-modal-toggle:hover {
  filter: brightness(1.1);
}

@media (max-width: 480px) {
  .player-modal-content { height: 588px; }
}
