/* ============================================================================
   HILOS DE COMUNIDAD — timeline estilo Twitter
   ============================================================================

   Va despues de 00-15 (el CSS historico troceado) para ganar la cascada sobre
   las reglas antiguas de `.community-thread-*`, que pintaban la lista como
   fichas. Aqui la columna es una sola pila de publicaciones separadas por una
   linea, sin tarjetas ni sombras: el contenido es lo unico que se ve.

   Prefijo `tw-` = "timeline widget". Todo lo que pinta el hilo nuevo vive aqui.
   ========================================================================== */

/* Toda la pestana de Hilos comparte UNA columna centrada. Antes solo se
   estrechaba el timeline: el titulo se iba al borde izquierdo y "Crear hilo" al
   derecho, y la pagina se leia descuadrada. La regla se limita a `.is-threads`
   para no estrechar Anuncios ni Directos, que si usan el panel entero. */
/* Comunidad entera es UNA columna. Antes cada subpestana traia su propio ancho
   (Hilos estrecho, Anuncios y Directos a 1220px), asi que la barra de pestanas
   cambiaba de tamano al saltar de una a otra. Con una sola medida para
   cabecera, pestanas, contadores y paneles, la navegacion ya no se mueve.

   La seccion deja de centrarse sola a 1220px: ocupa el hueco entero y quien se
   centra es la columna. */
.community-card {
  width: 100%;
  margin-inline: 0;
}

.community-card .community-head,
.community-card .community-tab-shell,
.community-card .community-stats,
.community-card .community-layout,
.community-card #communityBoardPanel,
.community-card #communityLivesPanel {
  width: min(640px, 100%);
  margin-inline: auto;
}

/* Centrado OPTICO en escritorio. `.main-panels-content` reserva
   `--rail-gutter` a la izquierda para el carril y solo 24px a la derecha, asi
   que "centrar en el contenedor" deja la columna casi 100px a la derecha del
   centro real de la pantalla — el mismo desajuste que ya se corrigio en el
   inicio a pantalla completa. Aqui se calcula el margen izquierdo contra el
   viewport en vez de contra la caja padre; `max()` evita que la columna se
   meta debajo del carril en las ventanas mas justas. */
@media (min-width: 1025px) {
  .community-card .community-head,
  .community-card .community-tab-shell,
  .community-card .community-stats,
  .community-card .community-layout,
  .community-card #communityBoardPanel,
  .community-card #communityLivesPanel {
    margin-left: max(0px, calc(50vw - 320px - var(--rail-gutter)));
    margin-right: auto;
  }
}

.community-layout {
  gap: 0;
}

.community-threads {
  gap: 0;
}

/* --- Compositor ----------------------------------------------------------- */

.community-composer-slot {
  border-bottom: 1px solid var(--line);
}

.tw-composer {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 16px;
  align-items: start;
}

.tw-composer-rail {
  display: flex;
  justify-content: center;
}

.tw-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  object-fit: cover;
  flex: 0 0 auto;
}

.tw-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  object-fit: cover;
  flex: 0 0 auto;
}

.tw-composer-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.tw-composer-input {
  width: 100%;
  min-height: 52px;
  max-height: 320px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.4;
  padding: 10px 0 0;
  overflow-y: auto;
}

.tw-composer-input::placeholder {
  color: var(--text-soft);
}

/* La capa de tema pinta TODOS los textarea con marco, fondo y anillo lima al
   enfocar. En un compositor tipo Twitter el campo no debe existir visualmente,
   asi que se anula aqui con mas especificidad y el foco se marca en la linea
   inferior del compositor. */
.tw-composer-input:hover,
.tw-composer-input:focus,
.tw-composer-input:focus-visible,
.tw-reply-input:hover,
.tw-reply-input:focus,
.tw-reply-input:focus-visible {
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
}

.tw-composer-main:focus-within .tw-composer-foot {
  border-top-color: var(--line-neon);
}

.tw-composer-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.tw-composer-counter {
  font-size: 12px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.tw-composer-counter.is-near-limit {
  color: var(--primary);
}

.tw-composer-submit {
  border-radius: var(--radius-pill);
  padding: 8px 20px;
  font-weight: 700;
}

.tw-composer-submit[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.tw-composer-guest {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  grid-template-columns: none;
}

.tw-composer-guest-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tw-composer-guest-copy strong {
  font-size: 15px;
  color: var(--text);
}

.tw-composer-guest-copy span {
  font-size: 13px;
  color: var(--text-muted);
}

.tw-composer-guest .primary {
  border-radius: var(--radius-pill);
  padding: 8px 18px;
}

/* --- Publicacion (fila del timeline) -------------------------------------- */

.tw-post {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 16px 4px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  transition: background 0.14s ease;
}

.tw-post:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tw-post:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.tw-post.is-active {
  box-shadow: inset 2px 0 0 var(--primary);
}

.tw-post-rail {
  display: flex;
  justify-content: center;
}

.tw-post-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.tw-post-head {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
  line-height: 1.3;
}

.tw-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.tw-handle,
.tw-time,
.tw-dot {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
}

.tw-handle {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.tw-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  color: var(--text-muted);
}

.tw-badge-hot {
  color: #ffb45a;
  border-color: rgba(255, 180, 90, 0.35);
  background: rgba(255, 180, 90, 0.08);
}

.tw-badge-new {
  color: var(--primary);
  border-color: var(--line-neon);
  background: rgba(210, 243, 101, 0.08);
}

.tw-post-title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.tw-post-text {
  margin: 2px 0 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}

.tw-post-image {
  margin: 8px 0 4px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  max-height: 420px;
}

.tw-post-image img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
}

.tw-post-image-focus {
  max-height: 520px;
}

.tw-post-image-focus img {
  max-height: 520px;
}

/* --- Adjuntar imagen (compositor inline y modal) --------------------------- */

.tw-composer-attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--primary);
  cursor: pointer;
  font-size: 16px;
  margin-right: auto;
  transition: background 0.14s ease;
}

.tw-composer-attach:hover {
  background: rgba(210, 243, 101, 0.12);
}

.tw-composer-attach-modal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-right: 0;
}

.tw-composer-image-preview {
  position: relative;
  margin-top: 8px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  max-width: 320px;
}

.tw-composer-image-preview img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.tw-composer-image-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tw-composer-image-remove:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* --- Toggle "Mis hilos" ----------------------------------------------------- */

.tw-mine-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}

.tw-mine-toggle:hover {
  color: var(--text);
  border-color: var(--line-neon);
}

.tw-mine-toggle.is-active {
  color: var(--bg);
  background: var(--primary);
  border-color: var(--primary);
}

/* --- Barra de acciones ---------------------------------------------------- */

.tw-actions {
  display: flex;
  align-items: center;
  margin-top: 6px;
  /* Las acciones se reparten, pero en una franja corta: con el ancho completo
     de la columna quedaban tan separadas que dejaban de leerse como un grupo. */
  max-width: 300px;
  gap: 4px;
  justify-content: space-between;
}

.tw-action {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-pill);
  transition: color 0.14s ease;
}

.tw-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  transition: background 0.14s ease, color 0.14s ease;
  font-size: 15px;
}

.tw-action-count {
  min-width: 12px;
  text-align: left;
}

.tw-action-reply:hover {
  color: var(--primary);
}

.tw-action-reply:hover .tw-action-icon {
  background: rgba(210, 243, 101, 0.12);
}

.tw-action-like:hover,
.tw-action-like.is-on {
  color: #f4557f;
}

.tw-action-like:hover .tw-action-icon,
.tw-action-like.is-on .tw-action-icon {
  background: rgba(244, 85, 127, 0.12);
}

.tw-action-share:hover,
.tw-action-report:hover,
.tw-action-report.is-on {
  color: var(--primary);
}

.tw-action-share:hover .tw-action-icon,
.tw-action-report:hover .tw-action-icon,
.tw-action-report.is-on .tw-action-icon {
  background: rgba(210, 243, 101, 0.12);
}

.tw-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.tw-actions-sm {
  /* En una respuesta son solo tres iconos: van juntos, no repartidos. */
  max-width: none;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 2px;
}

.tw-actions-sm .tw-action-icon {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.tw-actions-lg {
  max-width: none;
  border-top: 1px solid var(--line);
  padding-top: 6px;
  margin-top: 8px;
  justify-content: space-around;
}

/* --- Vista de hilo (modal de detalle) ------------------------------------- */

/* La ficha venia a 900px con un degradado verde propio. La vista de un hilo se
   lee como la de un tweet: columna estrecha y el mismo suelo que el resto de
   paneles. Se encadena `.panel` para ganarle a la capa de tema, que carga
   despues de este fichero. */
.panel.community-thread-detail-modal-panel {
  width: min(640px, 96vw);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-color: var(--line);
}

.tw-post-focus {
  border-bottom: 0;
  cursor: default;
  padding: 4px 0 0;
}

.tw-post-focus:hover {
  background: transparent;
}

.tw-post-title-focus {
  font-size: 19px;
  -webkit-line-clamp: unset;
  display: block;
}

.tw-post-text-focus {
  font-size: 17px;
  line-height: 1.5;
  -webkit-line-clamp: unset;
  display: block;
}

.tw-post-stamp {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-soft);
}

.tw-post-tallies {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-muted);
}

.tw-post-tallies strong {
  color: var(--text);
  font-weight: 700;
}

.tw-menu-wrap {
  position: relative;
  margin-left: auto;
}

.tw-menu-toggle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 0;
  background: transparent;
}

.tw-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

/* Dentro de un modal, la capa de tema le pone marco a todo `.ghost`; el boton
   de tres puntos tiene que seguir siendo solo un icono. */
.modal .panel button.tw-menu-toggle {
  background: transparent;
  border: 0;
  color: var(--text-muted);
}

.modal .panel button.tw-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  color: var(--text);
}

.tw-menu {
  position: absolute;
  right: 0;
  top: 36px;
  z-index: 5;
  display: grid;
  gap: 2px;
  min-width: 190px;
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.tw-menu.hidden {
  display: none;
}

/* --- Respuestas ----------------------------------------------------------- */

.tw-replies {
  display: grid;
  gap: 0;
  margin-top: 4px;
}

.tw-reply {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0 6px;
  border-top: 1px solid var(--line);
}

.tw-reply-rail {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* La linea vertical que une una respuesta con las suyas, como el hilo de un
   tweet: nace bajo el avatar y baja hasta el final del bloque. */
.tw-reply-thread-line {
  flex: 1;
  width: 2px;
  margin-top: 6px;
  border-radius: 1px;
  background: var(--line);
}

.tw-reply-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.tw-reply-text {
  margin: 2px 0 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tw-reply-children {
  margin-top: 6px;
}

.tw-reply-children .tw-reply {
  border-top: 0;
  padding-bottom: 0;
}

.tw-reply-empty {
  padding: 18px 4px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  border-top: 1px solid var(--line);
}

/* --- Compositor de respuesta (pegado abajo) ------------------------------- */

.tw-reply-form {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 8px;
  padding-top: 8px;
  /* El fondo del panel termina en --surface: el degradado tiene que morir en
     ese color, o se veria una banda mas oscura bajo las respuestas. */
  background: linear-gradient(180deg, rgba(18, 27, 36, 0), var(--surface) 30%);
}

.tw-reply-target {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.tw-reply-target strong {
  color: var(--text);
}

.tw-reply-target-clear {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
}

.tw-reply-target-clear:hover {
  color: var(--primary);
}

.tw-reply-compose {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.tw-reply-compose:focus-within {
  border-color: var(--line-neon);
}

.tw-reply-compose-rail {
  display: flex;
  justify-content: center;
}

.tw-reply-input {
  width: 100%;
  min-height: 24px;
  max-height: 200px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  padding: 2px 0;
  overflow-y: auto;
}

.tw-reply-input::placeholder {
  color: var(--text-soft);
}

.tw-reply-submit {
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-weight: 700;
  white-space: nowrap;
}

/* --- Vacio y carga -------------------------------------------------------- */

.tw-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
}

.tw-empty i {
  font-size: 26px;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.tw-empty strong {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--text);
}

.tw-empty span {
  font-size: 14px;
}

.tw-skeleton-list {
  display: grid;
}

.tw-skeleton {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.tw-skeleton-avatar,
.tw-skeleton-lines i {
  display: block;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 240px 100%;
  animation: tw-shimmer 1.2s linear infinite;
}

.tw-skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
}

.tw-skeleton-lines {
  display: grid;
  gap: 8px;
  align-content: start;
  padding-top: 4px;
}

.tw-skeleton-lines i {
  height: 10px;
}

.tw-skeleton-lines i:nth-child(1) {
  width: 40%;
}

.tw-skeleton-lines i:nth-child(2) {
  width: 92%;
}

.tw-skeleton-lines i:nth-child(3) {
  width: 68%;
}

@keyframes tw-shimmer {
  from {
    background-position: -240px 0;
  }
  to {
    background-position: 240px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tw-skeleton-avatar,
  .tw-skeleton-lines i {
    animation: none;
  }
}

/* --- Movil ---------------------------------------------------------------- */

@media (max-width: 720px) {
  .tw-composer,
  .tw-post,
  .tw-skeleton {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
    padding-inline: 12px;
  }

  .tw-avatar {
    width: 40px;
    height: 40px;
  }

  .tw-composer-input {
    font-size: 17px;
  }

  .tw-actions {
    max-width: 280px;
  }

  .tw-name {
    max-width: 140px;
  }

  .tw-handle {
    max-width: 110px;
  }

  .tw-post-focus {
    padding-inline: 0;
  }

  .tw-reply-compose {
    grid-template-columns: 32px minmax(0, 1fr) auto;
  }

  .tw-avatar-sm {
    width: 32px;
    height: 32px;
  }

  .tw-reply-submit {
    padding: 8px 12px;
  }
}
