/* Room watch-together component.
 * Playback/server state lives in room_watch.js + room_watch_service.js.
 * This file owns the optional watch deck and its responsive UI. */
.room-watch-button.is-active {
  color: var(--hf-color-primary-text);
  background: rgba(var(--hf-color-primary-rgb), 0.12);
  border-color: rgba(var(--hf-color-primary-rgb), 0.3);
}

.room-watch-playing-indicator {
  width: 15px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.room-watch-playing-indicator i {
  display: block;
  width: 2px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center bottom;
}

.room-watch-playing-indicator--compact {
  width: 12px;
  height: 12px;
  gap: 1px;
}

.room-watch-playing-indicator--compact i {
  height: 7px;
}

.room-watch-button .room-watch-playing-indicator {
  display: none;
}

.room-watch-button.is-playing .room-watch-button-default-icon {
  display: none;
}

.room-watch-button.is-playing .room-watch-playing-indicator {
  display: inline-flex;
}

.room-watch-playing-indicator i:nth-child(1) {
  animation: room-watch-equalizer 0.8s ease-in-out infinite;
}

.room-watch-playing-indicator i:nth-child(2) {
  animation: room-watch-equalizer 0.8s ease-in-out 0.16s infinite;
}

.room-watch-playing-indicator i:nth-child(3) {
  animation: room-watch-equalizer 0.8s ease-in-out 0.32s infinite;
}

@keyframes room-watch-equalizer {
  0%,
  100% {
    transform: scaleY(0.45);
    opacity: 0.65;
  }

  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .room-watch-playing-indicator i {
    animation: none;
    transform: scaleY(0.75);
  }
}

.room-watch-panel {
  min-width: 0;
  box-sizing: border-box;
}

.room-watch-panel[hidden],
.room-watch-inline-form[hidden] {
  display: none !important;
}

.room-watch-player-shell {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #0d1115;
}

.room-watch-player-mount,
.room-watch-player-mount > div,
.room-watch-player-mount iframe {
  width: 100% !important;
  height: 100% !important;
}

.room-watch-player-mount {
  position: absolute;
  inset: 0;
}

.room-watch-player-mount[hidden],
.room-watch-overlay[hidden],
.room-watch-error[hidden] {
  display: none !important;
}

.room-watch-overlay,
.room-watch-error,
.room-watch-setup-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 18px;
  text-align: center;
  box-sizing: border-box;
}

.room-watch-overlay,
.room-watch-error {
  color: #fff;
  background: rgba(10, 16, 21, 0.9);
}

.room-watch-overlay p,
.room-watch-error p {
  max-width: 330px;
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
}

.room-watch-overlay button {
  min-height: 38px;
  padding: 0 14px;
  color: #fff;
  background: var(--hf-color-primary);
  border: 1px solid var(--hf-color-primary);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
}

.room-watch-setup-placeholder {
  display: none;
  color: rgba(255, 255, 255, 0.92);
  background:
    radial-gradient(
      circle at 48% 35%,
      rgba(67, 116, 141, 0.2),
      transparent 48%
    ),
    linear-gradient(145deg, #15212a, #0d1419);
}

.room-watch-panel.is-setup .room-watch-setup-placeholder {
  display: flex;
}

.room-watch-setup-placeholder .fa {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  font-size: 17px;
}

.room-watch-setup-placeholder strong {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.room-watch-setup-placeholder small {
  max-width: 250px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 10px;
  line-height: 1.45;
}

.room-watch-control,
.room-watch-mobile-topbar {
  position: relative;
  min-width: 0;
  box-sizing: border-box;
}

.room-watch-control-intro strong {
  display: block;
  color: var(--hf-color-text-strong);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
}

.room-watch-control-intro p {
  margin: 4px 0 0;
  color: var(--hf-color-muted);
  font-size: 10px;
  line-height: 1.45;
}

.room-watch-now {
  min-width: 0;
}

.room-watch-now > strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--hf-color-text-strong);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-watch-now > small,
.room-watch-mobile-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--hf-color-muted);
  font-size: 9px;
  line-height: 1.3;
}

.room-watch-now > small {
  margin-top: 4px;
}

.room-watch-state-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  background: var(--hf-color-success);
  border-radius: 50%;
}

.room-watch-panel[data-watch-state="paused"] .room-watch-state-dot,
.room-watch-panel[data-watch-state="ended"] .room-watch-state-dot {
  background: var(--hf-color-muted);
}

.room-watch-mobile-state-dot {
  display: none;
}

.room-watch-inline-form {
  min-width: 0;
}

.room-watch-inline-form label {
  margin: 0 0 6px;
  display: block;
}

.room-watch-inline-form label > span {
  color: var(--hf-color-text-strong);
  font-size: 10px;
  font-weight: 800;
}

.room-watch-inline-row {
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.room-watch-inline-row input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  color: var(--hf-color-text-strong);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(91, 115, 129, 0.22);
  border-radius: 9px;
  font-size: 11px;
  outline: none;
  box-sizing: border-box;
}

.room-watch-inline-row input:focus {
  border-color: rgba(var(--hf-color-primary-rgb), 0.58);
  box-shadow: 0 0 0 3px rgba(var(--hf-color-primary-rgb), 0.09);
}

.room-watch-inline-submit {
  min-width: 76px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0 10px;
  color: #fff;
  background: var(--hf-color-primary);
  border: 1px solid var(--hf-color-primary);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.room-watch-inline-submit:hover,
.room-watch-inline-submit:focus {
  background: var(--hf-color-primary-hover);
  border-color: var(--hf-color-primary-hover);
  outline: none;
}

.room-watch-inline-submit:disabled {
  opacity: 0.62;
  cursor: default;
}

.room-watch-inline-status {
  min-height: 12px;
  margin-top: 4px;
  margin-left: 1px;
  color: var(--hf-color-muted);
  font-size: 8px;
  line-height: 1.35;
}

.room-watch-inline-status.is-error {
  color: var(--hf-color-danger, #d95858);
}

.room-watch-mobile-topbar,
.room-watch-mobile-status {
  display: none;
}

body.room-chat-page .room-watch-close {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  color: var(--hf-color-muted);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(91, 115, 129, 0.14);
  border-radius: 9px;

  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

body.room-chat-page .room-watch-close:hover,
body.room-chat-page .room-watch-close:focus {
  color: var(--hf-color-text-strong);
  background: rgba(255, 255, 255, 0.8);
  outline: none;
}

body.room-chat-page .room-watch-panel-actions {
  display: none;
}

body.room-chat-page .room-watch-minimize-button[hidden] {
  display: none !important;
}

/* Desktop: preserve the existing watch deck visuals, but keep the deck in the
 * chat-window flex flow so the message viewport yields its height. */
@media (min-width: 901px) {
  body.room-chat-page .room-detail-layout.hf-chat-layout {
    position: relative;
  }

  body.room-chat-page #room_watch_panel {
    position: relative;

    width: calc(100% - 24px);
    height: clamp(200px, 35%, 228px);
    min-height: 200px;
    flex: 0 0 clamp(200px, 35%, 228px);

    align-self: center;
    margin: 12px 12px 16px;

    display: grid;
    grid-template-columns: auto minmax(0, 1fr);

    padding: 0;
    overflow: hidden;

    background: transparent;
    /* border: 1px solid rgba(255, 255, 255, 0.62); */
    border-radius: 12px;

    box-shadow:
      0 4px 12px rgba(20, 39, 51, 0.15),
      0 1px 4px rgba(20, 39, 51, 0.1);
  }

  body.room-chat-page #room_watch_panel[hidden] {
    display: none !important;
  }

  body.room-chat-page .room-watch-control > .room-watch-panel-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  body.room-chat-page .room-watch-player-shell {
    width: auto;
    height: 100%;
    justify-self: start;
    aspect-ratio: 16 / 9;
    border-radius: 11px 0 0 11px;
  }

  body.room-chat-page .room-watch-control {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 14px 14px 6px;
    overflow: hidden;
    background: rgba(249, 251, 252, 0.81);
    border-left: 1px solid rgba(91, 115, 129, 0.13);
  }

  body.room-chat-page #room_watch_panel.is-minimized {
    height: 120px;
    min-height: 120px;
    flex-basis: 120px;
  }

  body.room-chat-page #room_watch_panel.is-minimized .room-watch-control-intro {
    padding-right: 76px;
  }

  body.room-chat-page #room_watch_panel.is-minimized .room-watch-inline-form {
    display: none !important;
  }

  body.room-chat-page #room_watch_panel.is-minimized .room-watch-control {
    padding-top: 12px;
    padding-bottom: 8px;
  }

  body.room-chat-page #room_watch_panel.is-minimized .room-watch-now {
    margin-top: 8px;
    padding: 8px 0 0;
  }

  body.room-chat-page .room-watch-now {
    margin-top: 11px;
    padding: 12px 0 8px;
    border-top: 1px solid rgba(91, 115, 129, 0.12);
  }

  body.room-chat-page .room-watch-panel.is-setup .room-watch-now {
    display: none !important;
  }

  body.room-chat-page .room-watch-panel.is-setup .room-watch-inline-form {
    margin-top: 15px;
  }

  body.room-chat-page
    .room-watch-panel:not(.is-setup)
    .room-watch-inline-form
    label {
    display: none;
  }

  body.room-chat-page .room-detail-view.is-watch-visible #room_messages {
    padding-top: 0;
  }
}

/* Mobile: information / video / actions are three separate rows. The deck is
 * part of the chat-window flex flow so messages shrink while the composer stays
 * anchored by the existing application shell. */
@media (max-width: 900px) {
  body.room-chat-page .room-detail-layout.hf-chat-layout {
    position: relative;
  }

  body.room-chat-page #room_watch_panel {
    position: relative;
    width: 100%;
    max-width: none;
    flex: 0 0 auto;
    align-self: stretch;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-rows: auto auto auto;
    overflow: hidden;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--hf-color-line);
    border-radius: 0;
    box-shadow: none;
  }

  body.room-chat-page #room_watch_panel[hidden],
  body.room-chat-page #room_watch_panel.is-setup {
    display: none !important;
  }

  body.room-chat-page .room-watch-mobile-topbar {
    min-height: 36px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    padding: 4px 6px 4px 10px;
    background: rgba(249, 251, 252, 0.8);
    border-bottom: 1px solid rgba(91, 115, 129, 0.12);
    -webkit-backdrop-filter: blur(14px) saturate(118%);
    backdrop-filter: blur(14px) saturate(118%);
  }

  body.room-chat-page .room-watch-mobile-label {
    color: var(--hf-color-text-strong);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
  }

  body.room-chat-page .room-watch-mobile-title {
    width: 100%;
    max-width: 48vw;
    min-width: 0;
    overflow: hidden;
    color: var(--hf-color-muted);
    font-size: 9px;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.room-chat-page .room-watch-mobile-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
  }

  body.room-chat-page .room-watch-mobile-minimize-button[hidden] {
    display: none !important;
  }

  body.room-chat-page .room-watch-mobile-expand-label {
    display: none;
  }

  body.room-chat-page .room-watch-mobile-close {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--hf-color-muted);
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(101, 122, 134, 0.14);
    border-radius: 9px;
    font-size: 11px;
  }

  body.room-chat-page .room-watch-mobile-close:hover,
  body.room-chat-page .room-watch-mobile-close:focus {
    color: var(--hf-color-text-strong);
    background: rgba(255, 255, 255, 0.8);
    outline: none;
  }

  body.room-chat-page .room-watch-player-shell {
    width: 100%;
    min-height: 200px;
    aspect-ratio: 16 / 9;
    border-radius: 0;
  }

  body.room-chat-page .room-watch-control {
    min-height: 44px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px;
    padding: 6px 8px 6px 10px;
    background: rgba(249, 251, 252, 0.8);
    border-top: 1px solid rgba(91, 115, 129, 0.12);
    -webkit-backdrop-filter: blur(14px) saturate(118%);
    backdrop-filter: blur(14px) saturate(118%);
  }

  body.room-chat-page .room-watch-control-intro,
  body.room-chat-page .room-watch-now,
  body.room-chat-page .room-watch-inline-form,
  body.room-chat-page .room-watch-control > .room-watch-panel-actions {
    display: none !important;
  }

  body.room-chat-page .room-watch-mobile-status {
    min-width: 0;
    display: flex;
    white-space: nowrap;
  }

  body.room-chat-page .room-watch-overlay,
  body.room-chat-page .room-watch-error {
    padding: 14px;
  }

  body.room-chat-page
    .room-detail-layout.hf-chat-layout
    > .room-participant-panel.hf-chat-side-panel.is-mobile-open {
    z-index: 8;
  }

  body.room-chat-page
    #room_watch_open_button.is-playing
    .room-watch-playing-indicator {
    display: inline-flex !important;
  }

  body.room-chat-page #room_watch_panel.is-mobile-minimized {
    grid-template-columns: minmax(0, 65%) minmax(0, 35%);
    grid-template-rows: auto;
    align-items: stretch;
    background: var(--hf-color-surface-elevated);
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-player-shell {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-height: 0;
    height: auto;
    aspect-ratio: 16 / 9;
    align-self: stretch;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-mobile-topbar {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 5px;
    padding: 8px 7px 7px 9px;
    border-bottom: 0;
    border-left: 1px solid var(--hf-color-line);
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-mobile-label {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    flex: 0 0 auto;
    gap: 5px;
    color: var(--hf-color-text-strong);
    font-size: 10px;
    line-height: 1.15;
    white-space: nowrap;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-mobile-state-dot {
    display: block;
    width: 6px;
    height: 6px;
    flex-basis: 6px;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-mobile-title {
    display: -webkit-box;
    width: 100%;
    max-width: none;
    min-width: 0;
    overflow: hidden;
    color: var(--hf-color-muted);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-mobile-actions {
    width: 100%;
    margin-top: auto;
    gap: 5px;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-mobile-minimize-button {
    width: auto;
    min-width: 0;
    height: 28px;
    flex: 1 1 auto;
    gap: 4px;
    padding: 0 7px;
    border-radius: 8px;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-mobile-expand-label {
    display: inline;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    #room_watch_mobile_hide_button {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 8px;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-control {
    display: none !important;
  }

  body.room-chat-page .room-detail-view.is-watch-visible #room_messages {
    padding-top: 0;
    box-shadow: inset 0 8px 10px -10px rgba(20, 39, 51, 0.28);
  }
}

@media (max-width: 360px) {
  body.room-chat-page
    #room_watch_panel:not(.is-mobile-minimized)
    .room-watch-mobile-topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 5px;
    padding-left: 8px;
    padding-right: 5px;
  }

  body.room-chat-page .room-watch-mobile-title {
    max-width: 46vw;
  }

  body.room-chat-page .room-watch-mobile-topbar > .room-watch-close {
    width: 28px;
    height: 28px;
  }

  body.room-chat-page .room-watch-control {
    gap: 3px;
    padding-left: 8px;
    padding-right: 6px;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-mobile-topbar {
    gap: 4px;
    padding: 6px 6px 6px 8px;
  }

  body.room-chat-page
    #room_watch_panel.is-mobile-minimized
    .room-watch-mobile-title {
    font-size: 9px;
  }
}

html[data-hf-theme="dark"] body.room-chat-page .room-watch-control,
html[data-hf-theme="dark"] body.room-chat-page .room-watch-mobile-topbar,
html[data-hf-theme="dark"] body.room-chat-page #room_watch_panel {
  color: #e9f0f3;
}
html[data-hf-theme="dark"] body.room-chat-page #room_watch_panel {
  border-color: rgba(170, 188, 198, 0.18);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.3),
    0 1px 4px rgba(0, 0, 0, 0.5);
}
html[data-hf-theme="dark"] body.room-chat-page .room-watch-close {
  color: #c7d4da;
  background: rgba(10, 17, 23, 0.5);
  border-color: rgba(151, 171, 182, 0.18);
}

html[data-hf-theme="dark"] body.room-chat-page .room-watch-close:hover,
html[data-hf-theme="dark"] body.room-chat-page .room-watch-close:focus {
  color: #f1f6f8;
  background: rgba(25, 37, 46, 0.82);
  border-color: rgba(170, 188, 198, 0.28);
}

@media (min-width: 901px) {
  html[data-hf-theme="dark"] body.room-chat-page .room-watch-control {
    background: rgba(20, 30, 38, 0.82);
    border-left-color: rgba(151, 171, 182, 0.14);
  }
}

@media (max-width: 900px) {
  html[data-hf-theme="dark"] body.room-chat-page .room-watch-mobile-topbar,
  html[data-hf-theme="dark"] body.room-chat-page .room-watch-control {
    background: rgba(20, 30, 38, 0.82);
    border-color: rgba(170, 188, 198, 0.16);
  }
}

html[data-hf-theme="dark"] body.room-chat-page .room-watch-control-intro strong,
html[data-hf-theme="dark"] body.room-chat-page .room-watch-now > strong,
html[data-hf-theme="dark"]
  body.room-chat-page
  .room-watch-inline-form
  label
  > span,
html[data-hf-theme="dark"] body.room-chat-page .room-watch-mobile-label {
  color: #f1f6f8;
}

html[data-hf-theme="dark"] body.room-chat-page .room-watch-control-intro p,
html[data-hf-theme="dark"] body.room-chat-page .room-watch-now > small,
html[data-hf-theme="dark"] body.room-chat-page .room-watch-mobile-title,
html[data-hf-theme="dark"] body.room-chat-page .room-watch-mobile-status,
html[data-hf-theme="dark"] body.room-chat-page .room-watch-inline-status {
  color: #9fb0ba;
}

html[data-hf-theme="dark"] body.room-chat-page .room-watch-inline-row input {
  color: #eef4f6;
  background: rgba(10, 17, 23, 0.62);
  border-color: rgba(151, 171, 182, 0.2);
}
