/* IA Stream — modal (video view + comments)
 *
 * Styles the modal container used for:
 * - Expanded video playback
 * - Inline PeerTube comments
 *
 * Safe even if the modal is never opened.
 */

.ia-stream-modal {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Prevent Atrium fixed header from clipping the fullscreen modal on mobile */
@media (max-width: 640px) {
  .ia-stream-modal {
    align-items: flex-start;
    padding-top: 52px; /* matches typical Atrium top bar height */
  }
  .ia-stream-modal-dialog {
    height: calc(100% - 52px);
  }
}

/* Comment action buttons: Reddit-like compact controls */
.ia-stream-comment-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ia-stream-comment-vote,
.ia-stream-comment-del {
  background: transparent;
  border: 1px solid var(--ia-border, #2a3145);
  color: var(--ia-muted, #9aa3b2);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.ia-stream-comment-vote.is-on {
  color: var(--ia-text, #e6e8ee);
  border-color: var(--ia-text, #e6e8ee);
}

.ia-stream-comment-vote:hover,
.ia-stream-comment-del:hover {
  color: var(--ia-text, #e6e8ee);
  border-color: var(--ia-text, #e6e8ee);
}

.ia-stream-vote-count {
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.ia-stream-modal[hidden] {
  display: none;
}

/* Typography tweaks inside the fullscreen video modal */
.ia-stream-modal .iad-card-title{ font-size: 1.25rem; line-height: 1.2; font-weight: 700; }
.ia-stream-modal .iad-card-excerpt, .ia-stream-modal .ia-stream-support{ font-size: 0.95rem; line-height: 1.45; }
.ia-stream-modal .iad-sub{ font-size: 0.875rem; }

/* Jump-to-comment highlight */
.ia-stream-highlight{ outline: 2px solid rgba(255,255,255,0.25); outline-offset: 4px; border-radius: 12px; }

/* Minimal auth prompt modal (used only for retro user provisioning / token mint) */
.ia-stream-auth-modal {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.ia-stream-auth-dialog {
  width: 100%;
  max-width: 460px;
  background: var(--ia-panel, #151922);
  border: 1px solid var(--ia-border, #2a3145);
  border-radius: var(--ia-radius, 12px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  overflow: hidden;
}

.ia-stream-auth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ia-border, #2a3145);
}

.ia-stream-auth-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ia-text, #e6e8ee);
}

.ia-stream-auth-x {
  background: transparent;
  border: none;
  color: var(--ia-muted, #9aa3b2);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
}

.ia-stream-auth-x:hover {
  color: var(--ia-text, #e6e8ee);
}

.ia-stream-auth-body {
  padding: 12px;
}

.ia-stream-auth-msg {
  color: var(--ia-text, #e6e8ee);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.ia-stream-auth-label {
  display: block;
  color: var(--ia-muted, #9aa3b2);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.ia-stream-auth-input {
  width: 100%;
  border-radius: var(--ia-radius, 10px);
  border: 1px solid var(--ia-border, #2a3145);
  background: var(--ia-card, #1b2030);
  color: var(--ia-text, #e6e8ee);
  padding: 10px;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.ia-stream-auth-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ia-stream-auth-btn {
  border-radius: var(--ia-radius, 10px);
  border: 1px solid var(--ia-border, #2a3145);
  background: transparent;
  color: var(--ia-text, #e6e8ee);
  padding: 8px 12px;
  cursor: pointer;
}

.ia-stream-auth-btn:hover {
  border-color: var(--ia-text, #e6e8ee);
}

.ia-stream-modal-dialog {
  width: 100%;
  max-width: 100%;
  height: 100%;
  background: var(--ia-panel, #151922);
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

/* Header */
.ia-stream-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ia-border, #2a3145);
}

.ia-stream-modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ia-text, #e6e8ee);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ia-stream-modal-close {
  background: transparent;
  border: none;
  color: var(--ia-muted, #9aa3b2);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
}

.ia-stream-modal-close:hover {
  color: var(--ia-text, #e6e8ee);
}

/* Body */
/* Body
   - Mobile: natural document scroll
   - Desktop: split view (video left, comments right with its own scroll)
*/
.ia-stream-modal-body {
  flex: 1 1 auto;
  background: var(--ia-bg, #0f1115);
  overflow: hidden;
}

.ia-stream-modal-layout {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
}

.ia-stream-modal-left,
.ia-stream-modal-right {
  min-width: 0;
}

/* Video area */
.ia-stream-modal-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: black;
}

.ia-stream-modal-video iframe,
.ia-stream-modal-video video {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Meta / description */
.ia-stream-modal-meta {
  padding: 12px;
  border-bottom: 1px solid var(--ia-border, #2a3145);
}

/* Match Discuss typography more closely inside the modal meta block */
.ia-stream-modal-meta .iad-card-meta{
  font-size: 0.8rem;
  color: var(--ia-muted, #9aa3b2);
}

.ia-stream-modal-meta .iad-card-title{
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: 0.2px;
}

.ia-stream-modal-meta .iad-card-excerpt p{
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ia-text, #e6e8ee);
}

.ia-stream-modal-meta p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ia-text, #e6e8ee);
}

.ia-stream-modal-sub {
  font-size: 0.8rem;
  color: var(--ia-muted, #9aa3b2);
  margin-top: 4px;
}

/* Comments */
.ia-stream-modal-comments {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
}

/* Thread replies container (rendered by JS) */
.ia-stream-thread-children {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Collapse replies without refetching */
.ia-stream-thread.is-collapsed .ia-stream-thread-children {
  display: none;
}

.ia-stream-comment-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.ia-stream-comment-actions button {
  background: transparent;
  border: none;
  color: var(--ia-muted, #9aa3b2);
  cursor: pointer;
  padding: 0;
  font-size: 0.8rem;
}

.ia-stream-comment-actions button:hover {
  color: var(--ia-text, #e6e8ee);
}

.ia-stream-comment-vote {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 2px 6px;
  line-height: 1;
}

.ia-stream-comment-vote.is-on {
  color: var(--ia-text, #e6e8ee);
  border-color: var(--ia-border, #2a3145);
  background: rgba(255,255,255,0.03);
}

.ia-stream-comment-del {
  opacity: 0.85;
}

.ia-stream-comment-del:hover {
  opacity: 1;
}

.ia-stream-comment-children {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ia-stream-comment.is-child {
  margin-left: 18px;
  border-left: 2px solid var(--ia-border, #2a3145);
}

.ia-stream-comment-toggle {
  font-size: 0.8rem;
  color: var(--ia-muted, #9aa3b2);
}

/* Composer (top-level) */
.ia-stream-modal-composer {
  position: sticky;
  top: 0;
  background: var(--ia-panel, #151922);
  border-bottom: 1px solid var(--ia-border, #2a3145);
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  z-index: 2;
}

/* Inline reply composer (shown under a comment only when replying) */
.ia-stream-inline-reply {
  margin-top: -4px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: var(--ia-radius, 10px);
  border: 1px solid var(--ia-border, #2a3145);
  background: rgba(0,0,0,0.12);
}

.ia-stream-inline-reply-meta {
  font-size: 0.8rem;
  color: var(--ia-muted, #9aa3b2);
  margin-bottom: 6px;
}

.ia-stream-inline-reply-input {
  width: 100%;
  resize: none;
  border-radius: var(--ia-radius, 10px);
  border: 1px solid var(--ia-border, #2a3145);
  background: var(--ia-card, #1b2030);
  color: var(--ia-text, #e6e8ee);
  padding: 8px 10px;
  font-size: 0.9rem;
}

.ia-stream-inline-reply-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.ia-stream-inline-reply-actions button {
  border-radius: var(--ia-radius, 10px);
  border: 1px solid var(--ia-border, #2a3145);
  background: var(--ia-card, #1b2030);
  color: var(--ia-text, #e6e8ee);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

.ia-stream-inline-reply-actions button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Desktop split: video pinned left, comments scroll right */
@media (min-width: 900px) {
  .ia-stream-modal-layout {
    flex-direction: row;
    overflow-y: hidden;
    padding-bottom: 0;
  }

  .ia-stream-modal-left {
    flex: 0 0 55%;
    border-right: 1px solid var(--ia-border, #2a3145);
    display: flex;
    flex-direction: column;
  }

  .ia-stream-modal-video {
    max-height: 60vh;
  }

  .ia-stream-modal-right {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .ia-stream-modal-comments {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
  }
}

.ia-stream-composer-input {
  flex: 1 1 auto;
  resize: none;
  border-radius: var(--ia-radius, 10px);
  border: 1px solid var(--ia-border, #2a3145);
  background: var(--ia-card, #1b2030);
  color: var(--ia-text, #e6e8ee);
  padding: 8px 10px;
  font-size: 0.9rem;
}

.ia-stream-composer-send {
  flex: 0 0 auto;
  border-radius: var(--ia-radius, 10px);
  border: 1px solid var(--ia-border, #2a3145);
  background: var(--ia-card, #1b2030);
  color: var(--ia-text, #e6e8ee);
  padding: 8px 12px;
  cursor: pointer;
}

.ia-stream-composer-send:disabled {
  opacity: 0.6;
  cursor: default;
}

.ia-stream-comment {
  background: var(--ia-card, #1b2030);
  border: 1px solid var(--ia-border, #2a3145);
  border-radius: var(--ia-radius, 10px);
  padding: 10px;
}

.ia-stream-comment-header {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.ia-stream-comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #333;
  flex-shrink: 0;
}

.ia-stream-comment-author {
  font-size: 0.85rem;
  font-weight: 600;
}

.ia-stream-comment-time {
  font-size: 0.75rem;
  color: var(--ia-muted, #9aa3b2);
}

.ia-stream-comment-text {
  font-size: 0.85rem;
  color: var(--ia-text, #e6e8ee);
  line-height: 1.4;
}

/* Mobile tweaks */
@media (max-width: 640px) {
  .ia-stream-comment.is-child { margin-left: 10px; }

  /* Small breathing room between the modal header and the player */
  .ia-stream-modal-video { margin-top: 8px; }
}

/* Desktop: split layout */
@media (min-width: 900px) {
  .ia-stream-modal-layout {
    flex-direction: row;
    overflow: hidden;
    padding-bottom: 0;
  }

  .ia-stream-modal-left {
    flex: 0 0 55%;
    border-right: 1px solid var(--ia-border, #2a3145);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .ia-stream-modal-video {
    max-height: 60vh;
    aspect-ratio: 16 / 9;
  }

  .ia-stream-modal-right {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  }
}
}
